我用存储过程断开一个数据库的所有连接时,怎么会发生‘只能结束用户进程’的错误??(在线)
存储过程如下:
create proc 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
GO
使用:
use master
exec killspid 'dltemp'
错误提示:‘只能结束用户进程’。