异常处理汇总-数据库系列 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干掉程序了