漂泊雪狼的博客

思考,讨论,分享C#,JavaScript,.NET,Oracle,SQL Server……技术
posts - 164, comments - 287, trackbacks - 9, articles - 10

导航

sql server 数据库变成单用户模式的恢复

Posted on 2017-09-19 11:46  漂泊雪狼  阅读(...)  评论(...编辑  收藏


USE master;
GO
DECLARE @SQL VARCHAR(MAX);
SET @SQL=''
SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID)
FROM master..sysprocesses
WHERE dbid=DB_ID('ty_active_log_gz');

EXEC(@SQL);

GO

ALTER DATABASE ty_active_log_gz SET MULTI_USER;