首页 > 代码库 > 清除数据库的关联

清除数据库的关联

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.sysprocesseswhere dbid=db_id(@dbname) ;OPEN tmpcur;fetch tmpcur into @spid ;while (@@FETCH_STATUS=0) begin     print @spid    if(@@spid!=@spid)--过滤自己的进程    begin       set @ddlstring=NKill +CONVERT( nvarchar,@spid) ;       execute sp_executesql @ddlstring ;   end   fetch tmpcur into @spid ; end ;close tmpcur ;deallocate tmpcur ;

 

清除数据库的关联