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;