当前位置:Gxlcms > 数据库问题 > sql server 强制关闭连接

sql server 强制关闭连接

时间:2021-07-01 10:21:17 帮助过:13人阅读

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   

人气教程排行