码迷,mamicode.com
首页 > 数据库 > 详细

sql server 强制关闭连接

时间:2018-11-30 20:21:29      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:RoCE   HERE   while   rtrim(   dealloc   begin   更改   open   lte   

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 强制关闭连接

标签:RoCE   HERE   while   rtrim(   dealloc   begin   更改   open   lte   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!