When calling SQL Server from a client using ODBC, if a long-running query is run causing the time specified in SQL_ATTR_QUERY_TIMEOUT to be exceeded, I see that control is returned to the application. My question is does the work continue within the SQL Server engine. If it does continue what can be done to abort/cancel/stop the request on the server? Is there a best practice consideration to keep in mind?
Share
The client sends an Attention signal to the server:
The engine will abort the batch at the first opportunity (for all practical reasons, right away) and send back the Attention ack. In certains states a batch cannot be interrupted, eg. while rolling back a transaction. In such case a client may request an abort, but the response will come only after the server terminates the non-interruptible work.
The above is true for any SQL Server client stack, eg. exactly the same is how
SqlCommand.CommandTimeoutworks.The
KILLcommand works in a very similar manner except that is not a client-server communication, but killing-SPID -> victim-SPID communication.