Rename SQL Server Database

Rename SQL Server Database:

Change the Database to Single User Mode and Rollback all the existing Transactions.
This is done because you need to obtain Exclusive Database Lock.
That way you don’t encounter errors related to obtaining database lock.
Rename the Database and then Turn on Multi User Accessibility.

USE master;
GO
ALTER DATABASE NMPortal
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO

USE master;
GO
ALTER DATABASE NMPortal
Modify Name = NMPortal_Backup;
GO

ALTER DATABASE NMPortal_Backup
SET MULTI_USER;
GO

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *