USE master; GO DECLARE @SQL VARCHAR(MAX); SET @SQL='' SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID) FROM master..sysprocesses WHERE dbid=DB_ID('数据库名'); EXEC(@SQL); ALTER DATABASE 数据库名 SET MULTI_USER;
USE master; GO DECLARE @SQL VARCHAR(MAX); SET @SQL='' SELECT @SQL=@SQL+'; KILL '+RTRIM(SPID) FROM master..sysprocesses WHERE dbid=DB_ID('数据库名'); EXEC(@SQL); ALTER DATABASE 数据库名 SET MULTI_USER;
转载于:https://www.cnblogs.com/zacklau/p/9780108.html