Track who is killing your sql queries using profiler

How you can track, who is killing your sql queries?


You can first find out your process id by querying sys.sysprocesses. 

You can enable sql profiler to track kill commands.

Steps

Login to SQL Server profiler pointing to the server where you are running you queries.
On trace properties window click on event selection.
Now on event selection select the procedure and sql batch check boxes as below.
Now you can click on column filter which open another window where you can select text data and add the filter as below.
Now click run to get trace on all queries containing kill command.

Another way is you can enable query history and then run the below command to search of queries run on server.

select login_name, session_id, host_name, host_process_id
from sys.dm_exec_sessions where host_process_id = XXXX AND session_id = YY

You can also check error log to find how the processe been killed.

EXEC xp_readerrorlog 0, 1, N'kill', NULL, NULL, NULL, N'DESC'

No comments:

Post a Comment

T-SQL LEAD LAG and SUM function based query

  Query on T-SQL window clause Below is the sales table Order_Date Name Product SubCategory ...