kill statement

greenspun.com : 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

Albert

-- Anonymous, March 29, 2000

Answers

Albert,

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,

Eric

-- Anonymous, March 29, 2000


Moderation questions? read the FAQ