user594166
user594166

Reputation:

finish the execution of sql server stored procedure

I'm calling an sql stored proc from ajax while debugging, I realized that its execution has been long. I have closed the page calling this proc via .ajax .

How can I check if the proc is not still running and how can I finish it from sql(script or manually).

Upvotes: 2

Views: 1356

Answers (1)

Martin Smith
Martin Smith

Reputation: 453278

To determine if any current sessions are executing the procedure you can use

Use YourDB

SELECT *
FROM sys.dm_exec_requests 
cross apply sys.dm_exec_query_plan(plan_handle)
where objectid=OBJECT_ID('YourSchema.YourProc')

(If your procedure calls other procedures you might need to tweak the above)

You can unceremoniously kill a session with kill <session_id> (if you have sufficient permissions) but be aware that if it was doing logged activity you might need to wait a long time for it to roll back.

Upvotes: 2

Related Questions