/ Published in: SQL
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
USE master GO DECLARE @dbname sysname SET @dbname = 'name of database you want to drop connections from' 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
URL: http://www.julian-kuiters.id.au/article.php/sql-server-2005-snippet-drop-db-conn