Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Kill All User Sessions Expand / Collapse
Author
Message
Posted Sunday, September 23, 2007 2:33 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, December 15, 2003 12:00 AM
Points: 45, Visits: 1
Comments posted to this topic are about the item Kill All User Sessions


Post #401541
Posted Sunday, December 16, 2007 9:40 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 3, 2014 1:24 PM
Points: 4, Visits: 414
I used a modifed version to block users from my database. Instead of using a cursor you can use...

declare @out nVarchar(4000)
SELECT @out = COALESCE (RTRIM(@out)+' Kill ' ,'')+ cast(spid as varchar(10))
from master..sysprocesses where db_name(dbid) = 'myDatabase' AND NT_USERNAME like @uid
set @out= 'kill ' + @out
execute sp_executesql @out


Post #433775
Posted Monday, December 7, 2009 1:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 5, 2014 7:43 AM
Points: 1, Visits: 96
DECLARE @SQL VARCHAR(8000)

SELECT @SQL = COALESCE(@SQL, '') + 'KILL ' + CAST(SPID AS VARCHAR(10)) + '; '
FROM SYS.SYSPROCESSES

SELECT @SQL

EXEC(@SQL)
Post #829687
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse