sql – 将数据库更改为“online”并将db设置为“multi-user”

前端之家收集整理的这篇文章主要介绍了sql – 将数据库更改为“online”并将db设置为“multi-user”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个离线的2008 sql数据库,我想在线并设置为多用户.使用sql server management studio – 新的查询窗口 – 当我执行以下命令时:
ALTER DATABASE mydb SET ONLINE;

    ALTER DATABASE mydb SET MULTI_USER;

我收到此错误消息:

Msg 5064,Level 16,State 1,Line 1
Changes to the state or options of
database ‘mydb’ cannot be made at this
time. The database is in single-user
mode,and a user is currently
connected to it.
Msg 5069,
State 1,Line 1 ALTER DATABASE
statement Failed. Msg 5064,Line 3 Changes to the state
or options of database ‘mydb’ 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,Line 3 ALTER
DATABASE statement Failed.

如何在线和多用户模式下获取数据库

解决方法

确保您不在该数据库中.关闭所有连接到它的查询窗口,关闭对象资源管理器详细信息,关闭SSMS并重新打开它,而不将对象资源管理器连接到该服务器,等等.运行:
USE [master];
GO

ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO

这应该允许您将其联机,然后您将运行您列出的命令.

猜你在找的MsSQL相关文章