Is there a way to detect errors if I use osql to execute sql statements?
Derek HartYou can use the -b switch and check ERRORLEVEL from a .BAT file, like
this:
@.echo off
osql -S servername -d databasename -E -b -Q "query"
if errorlevel 1 goto errormessage
echo OK
goto exit
:errormessage
echo Some error occurred !
:exit
Replace "query" with "select 1+1" or with "select 1/0", for example, to
test the different behaviour.
Razvan
No comments:
Post a Comment