DEFINITIONS

Definitions More Info.
Definition ID322
TitleSQL
CategorySCRIPT
DefinitionKilling sleeping process connecitons
Definition DescriptionDECLARE @v_spid INT
DECLARE c_Users CURSOR FAST_FORWARD FOR
SELECT SPID FROM master..sysprocesses (NOLOCK) WHERE spid>50
-- bu spid monitor den kill edilecek spid
AND status='sleeping'
-- 1 saatten fazla acik kalmis sessionlari oldurur.
--AND DATEDIFF(mi,last_batch,GETDATE())>=60
AND spid<>@@spid
OPEN c_Users
FETCH NEXT FROM c_Users INTO @v_spid
WHILE (@@FETCH_STATUS=0)
BEGIN PRINT 'KILLING '+CONVERT(VARCHAR,@v_spid)+'...' EXEC('KILL '+@v_spid)
FETCH NEXT FROM c_Users INTO @v_spid
END
CLOSE c_Users
DEALLOCATE c_Users

---------------------------------------------------------------
http://forums.asp.net/t/1026195.aspx
DECLARE @spid INT DECLARE kill_slp CURSOR FAST_FORWARD FOR
SELECT spid FROM master..sysprocesses (NOLOCK) where status='sleeping' and dbid=12
OPEN kill_slp
FETCH NEXT FROM kill_slp INTO @spid
WHILE (@@FETCH_STATUS=0)
BEGIN PRINT 'KILLing '+CONVERT(VARCHAR,@spid)+'...' EXEC('KILL '+@spid)
FETCH NEXT FROM kill_slp INTO @spid END CLOSE kill_slp
DEALLOCATE kill_slp


RecordBycunay
Record Date21-05-2013 11:06:04
Düzenle
Kopyala
Sil