|
database
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
trying unsuccessfully to produce OSQL errorI have a .CMD file with an OSQL command that does a simple -Q "DELETE
FROM MYTABLE". Under some circumstances this table does not exist, and I'd like to know about in the batch file. I'm trying to trap for this with: if errorlevel 1 goto :errorlabel But OSQL doesn't seem to set the DOS errorlevel if the query fails. Any thoughts? Are you using the -b parameter of osql?
Show quote "Rick Charnes" <rickxyz--nospam.zyxcharnes@thehartford.com> wrote in message news:MPG.1f69fe43a7c0a02798994c@msnews.microsoft.com... >I have a .CMD file with an OSQL command that does a simple -Q "DELETE > FROM MYTABLE". Under some circumstances this table does not exist, and > I'd like to know about in the batch file. I'm trying to trap for this > with: > > if errorlevel 1 goto :errorlabel > > But OSQL doesn't seem to set the DOS errorlevel if the query fails. Any > thoughts? THANK YOU! I hadn't known about this parm. Thanks much.
Btw, OSQLP Help for -b says: "The value returned to the DOS ERRORLEVEL variable is 1 when the SQL Server error message has a severity of 10 or greater..." The SQL error message I get is: Msg 208, Level 16, State 1,... Just to confirm: does "Level 16" indicate the "severity"? In article <elebTOp0GHA.4***@TK2MSFTNGP06.phx.gbl>, answer***@hotmail.com says... Show quote > Are you using the -b parameter of osql? > That's right.
"Rick Charnes" <rickxyz--nospam.zyxcharnes@thehartford.com> wrote in message Vyas, MVP (SQL Server)news:MPG.1f6a11b4eac83f5598994d@msnews.microsoft.com... > THANK YOU! I hadn't known about this parm. Thanks much. > > Btw, OSQLP Help for -b says: "The value returned to the DOS ERRORLEVEL > variable is 1 when the SQL Server error message has a severity of 10 or > greater..." > -- HTH, SQL Server Articles and Code Samples @ http://vyaskn.tripod.com/ Show quote > The SQL error message I get is: > > Msg 208, Level 16, State 1,... > > Just to confirm: does "Level 16" indicate the "severity"? > > > In article <elebTOp0GHA.4***@TK2MSFTNGP06.phx.gbl>, > answer***@hotmail.com says... >> Are you using the -b parameter of osql? >> |
|||||||||||||||||||||||