November 18, 2011 at 3:34 am
I'm stuck & would be v. grateful for help!!
I need a dos batch script to run a sql script.
SQL script will return 1 or 0.
batch script then needs to return an exit code of 1 or 0 to the 3rd party app.
dos batch:
sqlcmd -E -S WIN2008\SQLSRVR1 -icheck.sql
sql script:
IF (blah blah) = blah
print 'a'
ELSE
print'b'
-- (is print the right function to return to the dos batch?)
dos ...
?
-- how do i take the return code & if 0 exit /b 0, if 1 exit /b1 ?
Does this make any sense?!
p.s. For v. dull reasons out of my control I have only dos to do this with.
November 18, 2011 at 4:55 am
please dont quote me on this as i'm not the best person on dos, but I think you will need to get the script to fail as the script will always execute as a success and return a success error code.
could try somethink like RAISERROR in your script
IF (blahblah) = blahblah
begin
print 'a'--returns success code to dos
end
else
begin
print 'b'
raiserror(50000,16,1,'EPIC FAIL)--should return a failure code
end
might be what your looking for.
November 18, 2011 at 6:18 am
This thread should help you: http://www.sqlservercentral.com/Forums/FindPost1189112.aspx
-- Gianluca Sartori
November 18, 2011 at 7:49 am
Thanks guys!!! I'll take a look.
Appreciate your time.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply