How can I configure the xp_cmdshell command to execute a file through the command prompt including passing variables?
Posted on 2009-02-13
I am trying to use the xp_cmdshell sp in SQL Server 2000 to execute an exe file that requires variables. I can get it to execute the file but it won't add the variables.
I am trying to call sendmail.exe. When in a command window I can type:
c:\sendmail.exe -t email@example.com -f firstname.lastname@example.org -s test -m 10.100.1.1
and that works fine. However, when I put it in a SQL Server stored procedure:
set @cmdtest = 'c:\sendmail.exe -t email@example.com -f firstname.lastname@example.org -s test -m 10.100.1.1'
exec xp_cmdshell @cmdtest
when i run this i get a result back that is the same as entering 'c:\sendmail.exe 'in a command window. How can I get SQL Server to recognize the rest of the string that I'm passing to xp_cmdshell?
Thanks in Advance,