December 30, 2009 at 8:15 am
I need help correctly using the xp_cmdshell command.
This is the command I am trying to run:
C:\Program Files\Monarch Data Pump\PumpCmd.exe -q -s "MONARCH_JOB_NAME"
It works fine when I run from the command prompt. But I want to add it to a stored procedure.
I have tried using the following xp_cmdshell command with no luck.
exec master.dbo.xp_cmdshell 'dir C:\Program Files\Monarch Data Pump\PumpCmd.exe -q -s "MONARCH_JOB_NAME"', no_output
Please how do I write this correctly to make it work?
Thanks
December 30, 2009 at 8:37 am
Have you tried putting it in a .bat (batch) file and calling that? That's what I usually do with anything more complex than a dir command.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 30, 2009 at 9:12 am
i think filenames/paths with spaces need to be wrapped in double quotes, right?
also, are you not CALLING the datapump? why is the DIR command in there?
exec master.dbo.xp_cmdshell '"C:\Program Files\Monarch Data Pump\PumpCmd.exe" -q -s "MONARCH_JOB_NAME"', no_output
Lowell
December 30, 2009 at 9:57 am
Lowell (12/30/2009)
i think filenames/paths with spaces need to be wrapped in double quotes, right?also, are you not CALLING the datapump? why is the DIR command in there?
exec master.dbo.xp_cmdshell '"C:\Program Files\Monarch Data Pump\PumpCmd.exe" -q -s "MONARCH_JOB_NAME"', no_output
xp_cmdshell only deals with one set of double-quotes. Won't work if the second set is needed for the command to work.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 30, 2009 at 11:01 am
GSquared (12/30/2009)
Have you tried putting it in a .bat (batch) file and calling that? That's what I usually do with anything more complex than a dir command.
GSquared, Thanks. I put it in a batch file and it worked fine. I appreciate your help.
December 30, 2009 at 11:03 am
You're welcome.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
Viewing 6 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply