|
|
| |

How do I execute an operating-system command via Transact-SQL?
Answer:
You can use the xp_cmdshell extended stored procedure to
execute a given command string as an operating-system command shell
and return any output as rows of text.
This is the syntax of the xp_cmdshell:
xp_cmdshell {'command_string'} [, no_output]
where
'command_string' is varchar(255) or nvarchar(4000), with no default.
no_output - when used no output will be returned.
When executing xp_cmdshell with the Windows 9x operating systems, the return code will always be 0.
Executing this xp_cmdshell statement sends the 'Hello' message to JOHN:
EXEC master..xp_cmdshell "net send JOHN 'Hello'"
See SQL BOL for more information about the xp_cmdshell
extended stored procedure.
|
|
|