数据库名:test1
1. 查询数据库当前连接
select * from master.sys.sysprocesses where dbid = db_id('test1')
2. 断开指定连接
语法:kill spid号
如:
kill 58
3. 断开所有连接
declare @d varchar(8000) set @d= ' ' select @d=@d+ ' kill '+cast(spid as varchar)+char(13) from master.sys.sysprocesses where dbid=db_id('test1') exec(@d)