杀死数据库连接

use MASTER 
 
declare @spid int 
declare CUR cursor for 
select spid 
from   sysprocesses 
where  dbid = (select dbid 
from   sysdatabases 
where  name = 'ycmis') 
open cur 
fetch next from CUR into @spid 
 
while @@FETCH_STATUS = 0  
    begin 
        exec ('KILL ' + @spid ) 
        fetch next from CUR into @spid 
    end 
 
close CUR 
 
deallocate CUR 
 
  
 ---------------------------------------------------------------------------------
select  sysdatabases.* , 
        sysdatabases.name 
from    sysprocesses 
        join sysdatabases on sysprocesses.dbid = sysdatabases.dbid 
                             and name = 'ycmis' 
原文地址:https://www.cnblogs.com/qanholas/p/1874353.html