May 19, 2004 at 11:17 am
was wondering if anyone knew how to use xp_cmdshell to execute a .bat file. or, if that isn't possible, how i would call a .bat or .exe file from SQL Server 2k.
Thanks,
Matt
May 19, 2004 at 11:57 am
You would execute it as you would from a dos prompt, just within the xp_cmdshell parameters.
exec master..xp_cmdshell 'c:\folder\runthisfile.bat'
May 19, 2004 at 12:24 pm
EMs DTS and SQL Agent Job can also execute OS commands such as batch files.
DTS - Execute Process Task
Jobs - Step Type is Operating System Command (cmdExec)
hope this gives you options...
June 16, 2005 at 11:16 am
I have been trying to do the same thing in last few days but no luck. I am afraid the just executing following command does not work
exec master..xp_cmdshell 'D:\InventoryStaging\Batch\UnZip_Files.bat' . This is the result I get: "is not recognized as an internal or external command". And I dont want to use a DTS package.
Thanks,
Mahsa
June 16, 2005 at 11:35 am
Does the drive mapping exists on the server ? It's likely that the path to the batch file may exists on your PC and not on the server.
June 16, 2005 at 3:21 pm
The D: drive is local drive and that is why I don't understand why it does not work. I even copied the batch file to c: root but still it does not find it.
Thanks,
Mahsa
June 16, 2005 at 5:56 pm
Ok, The xp_cmshell did work. Unfortunately while naming my file name I accidently placed a space and that was why sql could not find it. But thank you guys for your help
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply