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

SQL Server ->> 无法将数据库从SINGLE_USER模式切换回MULTI_USER模式(Error 5064)

时间:2016-04-08 14:56:01      阅读:2647      评论:0      收藏:0      [点我收藏+]

标签:

报错信息如下:

Msg 5064, Level 16, State 1, Line 1
Changes to the state or options of database ‘test‘ cannot be made at this time. The database is in single-user mode, and a user is currently connected to it.
Msg 5069, Level 16, State 1, Line 1
ALTER DATABASE statement failed. 

 

有人还连着数据库,从下面步骤检查:

1)通过sys.sysprocesses或者sys.dm_exec_sessions,或者存储过程sp_who,然后用KILL命令把会话切断

select * from sys.sysprocesses 
where spid > 50
And dbid=DB_ID (MyDB)

 

SELECT * FROM sys.dm_exec_sessions
WHERE database_id = DB_ID (MyDB)

 

2)如果上面还是行不通,再检查sys.dm_tran_locks,然后用KILL命令把会话切断

select * from sys.dm_tran_locks where resource_database_id= DB_ID (MyDB)

 

SQL Server ->> 无法将数据库从SINGLE_USER模式切换回MULTI_USER模式(Error 5064)

标签:

原文地址:http://www.cnblogs.com/jenrrychen/p/5367711.html

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