The PROCSRV procedure sp_exec executes any command string in the operating-system environment in which PROCSRV is running, including batch files and other utilities. A string of parameters can be passed with the command. For example, if you have a mechanism for sending an automated electronic mail message from a batch file named SENDMAIL.CMD and the batch file takes the recipient's email name as a parameter, you can invoke the batch file from within SQL Server by issuing the following statement:
execute PROCSRV...sp_exec 'sendmail johndoe'
In this example, sendmail is the name of the external process (a command file), and johndoe is the parameter required by the external process. In SQL Server terms, these constitute one parameter of the sp_exec procedure, which then returns the results to the caller as a SQL Server results set.