江湖救急 SQL SERVER 2008 不能断开数据连接。
在master 里面建的存储过程
create proc [dbo].[killspid] (@dbname varchar(20)) as begin
declare @sql nvarchar(500)
declare @spid int
set @sql='declare getspid cursor for select spid from sysprocesses where dbid=db_id('''+@dbname+''')'
exec (@sql) open getspid fetch next from getspid into @spid while @@fetch_status <> -1
begin exec('kill '+@spid) fetch next from getspid into @spid end
close getspid deallocate getspid end
在执行的时候提示 “只能终止用户进程”
同样的存储过程在2005下 调试通过。