I'm having a little trouble with xp_cmdshell...wonder if anyone can spot anything incredibly stupid I'm missing.
This pdfcombine program just combines the first 2 files into one .pdf file. If I run the script below, it prints out 'GOOD'. along with the value of @CMD. But the file never gets created. However if I open a command prompt window using the same security context as the sqlserveragent account, copy the output from the PRINT @CMD, and run it, it works.
Am I missing something obvious? I've tried various combinations of quotes, and have even tried a full UNC path. In all cases, running the command in the command line works, but stops working as soon as I'm in SQL server. But I can do something simple like SET @CMD = 'DIR D:\' and that works.
DECLARE @CMD VARCHAR(512)
DECLARE @RESULT INT
SET @CMD =
'D:\JPMorgan_IMPORT\pdfcombine.exe D:\431411406.PDF D:\431411408.PDF D:\COMBINED.PDF'
EXECUTE @RESULT = master.dbo.xp_cmdshell @CMD
IF @RESULT = 0
The Redneck DBA