異常處理彙總-資料庫系列 http://www.cnblogs.com/dunitian/p/4522990.html
以前剛學資料庫的時候比較苦惱這個問題,今天删除的時候又看見了,正好一起記錄一下:
圖形化方法:

use master
go
declare @dbname sysname
set @dbname = 'BigValuesTest' --這個是要删除的資料庫庫名
declare @s nvarchar(1000)
declare tb cursor local
for
select s = 'kill ' + cast(spid as varchar)
from master.dbo.sysprocesses
where dbid = DB_ID(@dbname)
open tb
fetch next from tb into @s
while @@fetch_status = 0
begin
exec (@s)
fetch next from tb into @s
end
close tb
deallocate tb
exec ('drop database [' + @dbname + ']')
這個原理類似于作業系統裡面通過pid幹掉程式了
作者:
毒逆天出處:
https://www.cnblogs.com/dotnetcrazy打賞:
18i4JpL6g54yAPAefdtgqwRrZ43YJwAV5z本文版權歸作者和部落格園共有。歡迎轉載,但必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接!