Generic SQL action template for executing a command
- Last UpdatedMar 07, 2025
- 1 minute read
To configure a generic SQL statement that executes a command, select the "Invoke an External Application" option in the list of generic SQL action templates:
master..xp_cmdshell '<Your Command>', no_output
In the syntax, replace <Your Command> with the desired command. Be sure to enclose the command in single quotes. For example:
master..xp_cmdshell 'dir *.exe', no_output
The xp_cmdshell extended stored procedure does not start a Windows application. You can only execute simple DOS commands, batch files or executables (.EXEs) that do not display a user-interface window.
You must have the correct permissions set for the xp_cmdshell extended stored procedure for it to run. For more information, see your Microsoft SQL Server documentation.