Skip to main content

How to Rename SQL DB even when it is in USE ?

 

Use this script to rename your db.

This one sets single user mod first so that there is exclusive access, then rename the db and bring back to normal mode (multi_user mode)

 

USE master;
GO

ALTER DATABASE [Old_DB_Name]
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO

ALTER DATABASE [Old_DB_Name]
MODIFY NAME=
[New_DB_Name]
GO

ALTER DATABASE [New_DB_Name]
SET MULTI_USER WITH ROLLBACK IMMEDIATE
GO

Comments

Popular posts from this blog

How to accept outlook meeting invite via keyboard shortcut ?

There are two ways you can accept a meeting request. 1. when you are browsing list mail (and invite isn't opened) 2. wen you have opened the invite

Microsoft .NET Framework 3.0 (Brief Overview)

Topics:
What is the Microsoft .NET Framework 3.0?
What is Windows Communication Foundation ?
What is Windows Presentation Foundation ?
What is Windows Workflow Foundation?
What is Windows Card Space ?


What is the Microsoft .NET Framework 3.0?
The Microsoft .NET Framework 3.0 (formerly WinFX), is the new managed code programming model for Windows.