Q
Problem solve Get help with specific problems with your technologies, process and projects.

Killing orphaned processes within stored procedures

I want to perform the kill command from time to time to kill orphaned processes (that a specific application is leaving) within a stored procedure. The stored procedure syntax check will allow me to type "kill 750" where 750 is the spid to kill, but it will not allow me to use "kill @Id" where @Id is either a parameter in the parameter list or a variable within the stored procedure. Is there any way to do this, or is this a lost cause?

Take sp_who and dump it into a table. Open a cursor on the table. Using sp_executesql, dynamically execute the command you wish to run. There are dozens of instances of a script to perform this function. I'm not able to locate one as of this writing.

 

For More Information

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchDataCenter

SearchDataManagement

SearchAWS

SearchOracle

SearchContentManagement

SearchWindowsServer

Close