Rename SQL Server Database from sql queries

Queries to rename database in SQL Server :-

Step 1: Enable Single user mode on database 

ALTER DATABASE database_name
SET SINGLE_USER WITH ROLLBACK IMMEDIATE

Step 2: Change database name 

ALTER DATABASE database_name MODIFY NAME = New_database_name

Step 3: enable multi user mode on database 

ALTER DATABASE New_database_name
SET MULTI_USER WITH ROLLBACK IMMEDIATE

Its done :) 

Comments

Popular posts from this blog

FastEndpoint vs Minimal APIs vs Controller

Kick start 2021 ๐Ÿ˜ƒ๐Ÿ˜ƒ

Work with Raspberry PI Zero W