单用户改为多用户执行SQL:
USE master;
GO
declare @kid varchar(8000)
set @kid=''
select @kid=@kid+' kill '+cast(spid as varchar(8))
from master..sysprocesses
where dbid=db_id('DBname')
Exec(@kid)
GO
ALTER DATABASE DBname SET MULTI_USER
GO
多用户改为单用户执行SQL:
ALTER DATABASE DBname SET SINGLE_USER
设置数据库只读状态SQL:
ALTER DATABASE DBname SET READ_ONLY
官方文档:将数据库设置为单用户模式