Return value of SQLCMD
问题 I need to check the exit status (success/failure) of a query run through SQLCMD utility. For example, the server I am connecting doesn't have a database name EastWind . Then, the command below fails with the message ... > "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -S ZEPHIR -E -Q "USE WestWind" Changed database context to 'WestWind'. > echo %errorlevel% 0 > "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE" -S ZEPHIR -E -Q "USE EastWind" Database