1.

How Can You Execute A Dos Command From Sql Or Through Sql Query By Using Xp_cmdshell?

Answer»

exec xp_cmdshell 'dir c:*.exe'
xp_cmdshell {'command_string'} [, no_output]
Arguments
'command_string'
Is the command string to execute at the operating-system command shell. command_string is varchar(8000) or nvarchar(4000), with no default. command_string cannot contain more than one set of double quotation marks. A single pair of quotation marks is necessary if any spaces are PRESENT in the file PATHS or PROGRAM names referenced by command_string. If you have trouble with embedded spaces, consider using FAT 8.3 file names as a WORKAROUND.
no_output
Is an optional parameter executing the given command_string, and does not return any output to the client.

exec xp_cmdshell 'dir c:*.exe'
xp_cmdshell {'command_string'} [, no_output]
Arguments
'command_string'
Is the command string to execute at the operating-system command shell. command_string is varchar(8000) or nvarchar(4000), with no default. command_string cannot contain more than one set of double quotation marks. A single pair of quotation marks is necessary if any spaces are present in the file paths or program names referenced by command_string. If you have trouble with embedded spaces, consider using FAT 8.3 file names as a workaround.
no_output
Is an optional parameter executing the given command_string, and does not return any output to the client.



Discussion

No Comment Found