标签:
declare @spid int ; declare @ddlstring nvarchar(max); declare @dbname varchar(200); set @dbname=‘dbName‘; declare tmpcur cursor for select distinct spid as spid from sys.sysprocesses where dbid=db_id(@dbname) ; OPEN tmpcur; fetch tmpcur into @spid ; while (@@FETCH_STATUS=0) begin print @spid if(@@spid!=@spid)--过滤自己的进程 begin set @ddlstring=N‘Kill ‘+CONVERT( nvarchar,@spid) ; execute sp_executesql @ddlstring ; end fetch tmpcur into @spid ; end ; close tmpcur ; deallocate tmpcur ;
标签:
原文地址:http://www.cnblogs.com/zhshlimi/p/5853044.html