MSSQL : Rename DB that is having Can’t Exclusively Locked

Do you want to rename DB that is having can’t exclusively locked error message.

 

Try this.

ALTER DATABASE dbname
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
ALTER DATABASE dbnameMODIFY NAME = [dbname.DevData]
ALTER DATABASE [dbname.DevData]
SET MULTI_USER WITH ROLLBACK IMMEDIATE

 

God Bless!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.