/ Published in: SQL
Kill connections to a database to perform maintenance that requires a connectionless DB
- 1) Get the processes attached TO that DATABASE:
- SELECT spid FROM master..sysprocesses WHERE dbid = DB_ID(@DatabaseName)
- AND spid != @@SPID
- Note : @@SPID IS your connected instance Service Process id "SPID"
- 2) Perform KILL operation IN a loop OR USE cursor
- EXEC('KILL '+RTRIM(@spid) )
You need to login to post a comment.