当前位置: 代码迷 >> Sql Server >> 用kill为何报错了?解决方法
  详细解决方案

用kill为何报错了?解决方法

热度:5   发布时间:2016-04-27 15:51:42.0
用kill为何报错了?
use   master
go
declare   hyc   cursor   for
select   spid   from   sysprocesses   where   dbid=db_id( 'db_test ')
declare   @sd   int
open   hyc
while   @@fetch_status=0
begin
fetch   next   from   hyc   into   @sd
kill   @sd   --这里报错
end
close   hyc
deallocate   hyc

------解决方案--------------------

use master
go
declare hyc cursor for
select spid from sysprocesses where dbid=db_id( 'db_test ')
declare @sd int
open hyc
fetch next from hyc into @sd
while @@fetch_status=0
begin
exec( 'kill '[email protected]) --这里报错
fetch next from hyc into @sd
end
close hyc
deallocate hyc
  相关解决方案