help with SQLCMD

  • I want to run multiple SQL queries (on same database) saved as *.sql files automatically. Also saving the outputs in separate files.

    To achieve this i have written a query which creates a SQLCMD query dynamically and executes it.

    But using this approach even if one query errors out, next queries in queue runs. What i want is, if any query errors out, other queries should not be run.

    How can i achieve this ? or any other approach to this problem?

    Cheers

  • I assume you are running the sqlcmd's from a batch file ?

    after each sqlcmd use : IF ERRORLEVEL 1 goto ......

    which will evaluate to TRUE for any non-zero exit code for sqlcmd.

    The probability of survival is inversely proportional to the angle of arrival.

  • I am running these SQLCMD script from SSMS, using SQLCMDSHELL....!!!

    Cheers

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

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