为数据库镜像会话或可用性组中涉及的数据库将数据库设置为单用户模式

Set database to single user mode for database involved in database mirroring session or an availability group

我正在尝试将当前位于可用性组或镜像会话中的数据库设置为单用户模式。但我收到以下错误:

The operation cannot be performed on database "DATABASE_NAME" because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.ALTER DATABASE statement failed.

您需要将数据库从可用性组中移除,可以使用以下命令。

ALTER DATABASE DBName SET HADR OFF;  
GO

从 AlwaysOn AG 中删除数据库后,您可以将数据库置于 single-user 模式。