Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SQL Server Administration (2008)
 Kill all sessions

Author  Topic 

rohitmathur11
Yak Posting Veteran

77 Posts

Posted - 2009-12-07 : 02:40:03
Hi,
By useing sp_who i saw there are more then 1000 sessoins are sleeping . i want to kill all sessions, but i know to kill one sessions only like

KILL '100'

How to kill all sessions connected to database ...

any idea ..?

rajdaksha
Aged Yak Warrior

595 Posts

Posted - 2009-12-07 : 02:54:00
Hi


DECLARE @SQL VARCHAR(8000)

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

SELECT @SQL

EXEC (@SQL)


-------------------------
R...
Go to Top of Page

learntsql

524 Posts

Posted - 2009-12-07 : 07:39:47
Refer below link

http://www.mssqltips.com/tip.asp?tip=1247
Go to Top of Page
   

- Advertisement -