December 2013
Intermediate to advanced
1872 pages
153h 31m
English
One of the most useful, and potentially dangerous, extended stored procedures provided with SQL Server 2012 is xp_cmdshell. xp_cmdshell can execute any operating system command or program available on the SQL Server system, as long as it is a console program that doesn’t require user input. xp_cmdshell accepts a varchar(8000) (or nvarchar(4000)) value as the command string to be executed, and it returns the results of the command as a single nvarchar(255) column. The full syntax of xp_cmdshell is as follows:
xp_cmdshell { 'command_string' } [ , no_output ]
If the no_output option is specified, the results from the command are not displayed.
The following example uses xp_cmdshell to list the files ...