FIX: No error is prompted when connection is terminated in sqlcmd

Applies to: SQL Server 2012 DeveloperSQL Server 2012 EnterpriseSQL Server 2012 Standard


Assume that you use the sqlcmd utility to connect to a remote instance of Microsoft SQL Server 2012 or SQL Server 2014 and run a query with the -Q and -b option. When the sqlcmd connection is terminated unexpectedly before the query is finished, the exit code of sqlcmd indicates success.

  • The expected outcome is that when the sqlcmd connection is terminated, an error message is reported by sqlcmd that indicates that the connection is lost and the exit code is 1 that indicates failure.
  • The sqlcmd connection can be terminated in these ways: the SQL Server KILL command, SQL Server service shutdown, SQL Server restart during patching, network issues, and others.


After you apply this update, an error message together with severity 19 is sent back for the conditions described previously.

The issue was first fixed in the following cumulative update of SQL Server:


To work around this issue, use -i option instead of -Q option in sqlcmd to specify a query file that contains multiple query batches.


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.