首页 > 数据库技术 > 详细

sql server 强制关闭连接

时间:2018-11-30 19:30:27      阅读:317      评论:0      收藏:0      [点我收藏+]

USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=‘‘
SELECT @SQL=@SQL+‘; KILL ‘+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID(‘数据库名‘);

-- 更改数据库为多用户访问
EXEC(@SQL);
ALTER DATABASE 数据库名 SET MULTI_USER;

 

 

declare @i int declare cur cursor for select spid from sysprocesses where db_name(dbid)= ‘数据库名‘ open cur fetch next from cur into @i while @@fetch_status=0 begin exec(‘kill ‘+@i) fetch next from cur into @i end close cur deallocate cur

 

sql server 强制关闭连接

原文:https://www.cnblogs.com/csl0910/p/10045829.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!