Error status from ISQLW?

  • Does anyone know how a batch file can determine if ISQLW has processed SQL commands without errors?

    I was hoping to use IF ERRORLEVEL, but that doesn't seem to be working out for me. For example, this little batch file has a typo in the name of the Products table, but ISQLW returns an ERRORLEVEL of 0.

    echo SELECT * FROM Producks > Statements.sql

    isqlw -S localhost -d Northwind -U SA -P -i Statements.sql -o Results.txt

    echo Error level is %ERRORLEVEL%

    type Results.txt

  • That's because there is no fatal error, so isql exits correctly.

    I think you would need to trap the error and drop it into a table. Then query that table from another script and parse the results. Most likely you need to script this rather than use ISQL.

    Steve Jones

    sjones@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/sjones

    http://www.dkranch.net

  • Try using isql with -b parameter.

    Far away is close at hand in the images of elsewhere.
    Anon.

  • Just the solution I was looking for!

    For the record, both ISQL and OSQL support the -b option. The -b option returns an ERRORLEVEL of 1 for SQL Server errors with severity of 10 or greater.

    Thanks, John Craft

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply