Posted On October 29, 2021

T-SQL: How To Rename Database in Microsoft SQL Server

kimconnect 0 comments
blog.KimConnect.com >> Database >> T-SQL: How To Rename Database in Microsoft SQL Server

The T-SQL

USE master;  
GO  
ALTER DATABASE TEST_MSCRM SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE TEST_MSCRM MODIFY NAME = RENAMED_MSCRM;
GO  
ALTER DATABASE RENAMED_MSCRM SET MULTI_USER;
GO

Sample Output

Nonqualified transactions are being rolled back. Estimated rollback completion: 0%.
Nonqualified transactions are being rolled back. Estimated rollback completion: 100%.
The database name 'RENAMED_MSCRM' has been set.

Completion time: 2012-10-29T16:09:11.0019350-07:00

Leave a Reply

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

Related Post

MS SQL: Admin_Report_Notification

/* Admin_Report_Notification */DECLARE @tab char(1) SET @tab = CHAR(9)EXEC msdb.dbo.sp_send_dbmail@profile_name = 'Report DBMail Profile',@recipients =…

How to Add a Replica into an Existing Availability Group using PowerShell

Overview:0. Add secondary replica to the cluster by running some commands on the availability group…

How To Link Containers Using Docker Compose

This yields several advantages:1. Direct linking between containers is architectually efficient to direct traffic between…