Disconnect all Database Connections

0
9

Image

 

 

 

 

 

 

 

 

Declare @dbname sysname

Set @dbname = ‘name of database

Declare @spid int
Select @spid = min(spid) from master.dbo.sysprocesses
where dbid = db_id(@dbname)

While @spid Is Not Null
Begin
Execute (‘Kill ‘ + @spid)
Select @spid = min(spid) from master.dbo.sysprocesses
where dbid = db_id(@dbname) and spid > @spid
End

 

Source: http://gatekiller.co.uk/

LEAVE A REPLY

Please enter your comment!
Please enter your name here