I am using SQL server 2008 and its management studio. I executed a query that yields many rows. I tried to cancel it via the red cancel button, but it has not stopped for the past 10 minutes. It usually stops within 3 minutes.
What could the reason be and how do I stop it immediately ?
Use KILL SPID command to eliminate blocking in SQL Server Execute the following query in SSMS session. The SPID for this session is 60. In another session, it tries to get records of the table. The SPID for this session is 83.
SQL Server Management Studio Activity Monitor Once Activity Monitor has loaded, expand the 'Processes' section. Scroll down to the SPID of the process you would like to kill. Right click on that line and select 'Kill Process'. A popup window will open for you to confirm that you want to kill the process.
In SQL Developer, click Tools, then Monitor Sessions. In the Select Connection dialog box, select a connection to SYSTEM (or another account with full DBA privileges) Right-click in the row for the session to be terminated, and select Kill Session.
Expand SQL Server Agent, expand Jobs, right-click the job you want to stop, and then click Stop Job.
sp_who2 'active'
Check values under CPUTime and DiskIO. Note the SPID of process having large value comparatively.
kill {SPID value}
What could the reason be
A query cancel is immediate, provided that your attention can reach the server and be processed. A query must be in a cancelable state, which is almost always true except if you do certain operations like calling a web service from SQLCLR. If your attention cannot reach the server it's usually due to scheduler overload.
But if your query is part of a transaction that must rollback, then rollback cannot be interrupted. If it takes 10 minutes then it needs 10 minutes and there's nothing you can do about it. Even restarting the server will not help, it will only make startup longer since recovery must finish the rollback.
To answer which specific reason applies to your case, you'll need to investigate yourself.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With