Answers for "ALTER DATABASE failed because a lock could not be placed on database"

0

ALTER DATABASE failed because a lock could not be placed on database

USE master;

DECLARE @killSessions varchar(8000) = '';  
SELECT @killSessions = @killSessions + 'kill ' + CONVERT(varchar(5), spid) + ';'  
FROM master..sysprocesses  
WHERE dbid = db_id('dbname')
EXEC(@killSessions); 

ALTER DATABASE dbname SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE dbname SET OFFLINE WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE dbname  SET MULTI_USER;
Posted by: Guest on March-30-2020

Code answers related to "ALTER DATABASE failed because a lock could not be placed on database"

Browse Popular Code Answers by Language