use masterdeclare @dbname varchar(20)set @dbname='Bname'declare @sql nvarchar(500)declare @spid int--SPID 值是当用户进行连接时指派给该连接的一个唯一的整数set @sql='declare getspid cursor forselect spid from sysPRocesses where dbid=db_id('''+@dbname+''')'exec (@sql)open getspidfetch next from getspid into @spidwhile @@fetch_status<>-1--如果FETCH 语句没有执行失败或此行不在结果集中。beginexec('kill '+@spid)--终止正常连接fetch next from getspid into @spidendclose getspiddeallocate getspid
新闻热点
疑难解答