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 2005 Forums
 SQL Server Administration (2005)
 Kill sessions in a specific database

Author  Topic 

ksr39
Posting Yak Master

193 Posts

Posted - 2012-05-11 : 16:20:41
Hi Experts,

Is there any script to get all the sessions running/sleeping in a perticular database and can kill them all at a time.

Thank you all in advance.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-11 : 16:24:58
Use the same script but add dbid to your where clause: db_name(dbid) = 'SomeDatabase'

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-11 : 16:25:29
Although I would just use ALTER DATABASE to get everyone out as that sounds like that's what you want.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ksr39
Posting Yak Master

193 Posts

Posted - 2012-05-11 : 16:28:22
Thank you Kizer,

You mean I need to bring the database into single user mode..?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-11 : 16:44:10
Not necessarily single user mode, but yes one of those. If the users don't have dbowner, then you can use RESTRICTED_USER.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

ksr39
Posting Yak Master

193 Posts

Posted - 2012-05-11 : 16:56:30
Ok Thank you Tara for the Information.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2012-05-11 : 17:07:07
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -