News

Copyright © 2008-2019 Paula DiTallo

Tag Cloud



How Do I Change a Database Instance Name in SQL Server?

Ten minutes ago I created a scratch db instance with a name I mistyped. Not good!   Fortunately, I have admin privileges so I can change it in my lab environment.  If you're an admin AND no other users are accessing the DB instance, here's what you can do:

USE master
go
EXEC sp_renamedb 'MetroWrongName', 'MetroRightName'
GO

If someone is using the instance, there is a workaround. Do this:

 

USE master
go

-- flag the instance for single user only

EXEC sp_dboption 'MetroWrongName','Single User', True
GO

-- make the name change with the rename sproc
EXEC sp_renamedb 'MetroWrongName', 'MetroRightName'
GO

-- flag the newly named instance back to mulitusers

EXEC sp_dboption 'MetroRightName','Single User', False
GO

Friday, May 27, 2011 4:38 PM

Feedback

# re: How Do I Change a Database Instance Name in SQL Server?

make the name change with the rename sproc
EXEC sp_renamedb 'MetroWrongName', 'MetroRightName' 8/16/2011 4:25 AM | Official Eagles Jersey

Post A Comment
Title:
Name:
Email:
Comment:
Verification: