September 27, 2005 at 8:02 pm
I'm trying to execute two DOS commands in one job step, but am unsuccessful. Is this possible?
IF EXISTS \\Server\C$\File.txt
ECHO JOB COMPLETED > \\Server\C$\File.txt
Is a SQL job step limited to one DOS command per step?
Thanks, Dave
September 28, 2005 at 3:26 am
Hi Dave,
i am not sure if we can execute 2 dos commands at one time. what i undertand from the description above is that u need to delete a file if it exists thru a job. i feel, that you can use the script below in the job and try it out.
DECLARE @result int
EXEC @result = xp_cmdshell 'dir *.exe1'
IF (@result = 0)
PRINT 'Success' <place your commands here>
ELSE
PRINT 'Failure' <place your commands here>
hope this helps you.
September 28, 2005 at 7:25 am
Another way is to put all your dos command in a bat file. Run the bat file from sql job
September 28, 2005 at 7:33 am
If I put all of the DOS commands in a bat file is there a way to know if each command completed successfully?
Dave
September 28, 2005 at 7:40 am
Yes. try exit with different number in your bat
e.g. :
EXIT 3
September 28, 2005 at 7:42 am
I'll give it a try. Thanks for the help.
Dave
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply