kill statement : LUSENET : SQL Server Database Administration : One Thread

Eric, could you tell me please, if there's any statement(or system SP) I can use to kill process instead of "KILL"? The reason why I ask you, I want to scheduled job that will look for the processes that running more then, say 5hrs and kill it. Since I don't know the SPID of this processes I would like to dynamically asign to a variable. But I can't do it with KILL as you know. Thank you


-- Anonymous, March 29, 2000



To KILL with a variable, try something like this:

declare @killspid int

declare @killcmd varchar(50)

set @killspid = 7 -- Calculate your spid here.

set @killcmd ='KILL ' + str(@killspid)

exec (@killcmd)

Hope this helps,


-- Anonymous, March 29, 2000

Moderation questions? read the FAQ