How to kill database all users
USE master
Go
DECLARE @dbid INT , @spid INT , @STR NVARCHAR(500)
--Replace
dbname with your database name
SET @dbid = DB_ID('dbname')
DECLARE rs SCROLL CURSOR FOR
SELECT spid FROM sysprocesses WHERE dbid = @dbid
OPEN rs
FETCH FIRST FROM rs INTO @spid
WHILE @@fetch_status= 0
BEGIN
SELECT @STR = 'KILL '
+ CONVERT ( VARCHAR(10) , @spid )
EXEC sp_executesql @STR
FETCH NEXT FROM rs INTO @spid
END
CLOSE rs
DEALLOCATE rs
I appreciate the time you spent finding that information
ReplyDeleteThanks for your feedback
DeleteThanks for your information
ReplyDeleteThanks for your feedback
Delete