use master; go declare @temp nvarchar(20) declare myCurse cursor for select spid from sys.sysprocesses where dbid=DB_ID('資料庫名稱')--待清理的資料庫 open myCurse ...
use master; go declare @temp nvarchar(20) declare myCurse cursor for select spid from sys.sysprocesses where dbid=DB_ID('資料庫名稱')--待清理的資料庫 open myCurse fetch next from myCurse into @temp while @@FETCH_STATUS=0 begin exec('kill '+ @temp) fetch next from myCurse into @temp end close myCurse deallocate myCurse;