Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Can somebody tell me how to rename the DB server instance name and a DB name in SQL Server 2005?

Right Now I Have

SERVER/OLDNAME

-- oldnameDB

I want to change the server instance and also change the db name.

I have tried:

EXEC sp_renamedb 'oldName', 'newName'

and that has changed the dbname as it appers in the tree directory. But, when I do "select @@servername" it is the old name. Also, the MDF and LDF files are still the old name.

How do change instance and db names as a clean sweep across the server?

Thanks.

share|improve this question

migrated from stackoverflow.com Mar 15 '10 at 3:08

This question came from our site for professional and enthusiast programmers.

    
This belongs on ServerFault.com. –  David Stratton Mar 13 '10 at 20:37
add comment

2 Answers 2

up vote 2 down vote accepted

Note, there is no article in MSDN to rename instances. This may be the closest: How to: Rename a Computer that Hosts a Stand-Alone Instance of SQL Server.

Frankly I'd reinstall if you want to chance instance name

sp_renamedb (deprecated, use ALTER DATABASE) will only change the name in sys.databases. You'll have detach, rename files, reattach. Or backup/restore WITH MOVE

share|improve this answer
add comment

it's possible with sp_addserver and some registry edits

see oj's comment here:

http://www.sqlnewsgroups.net/group/microsoft.public.sqlserver.server/topic15810.aspx

or the other option is re-install and reload the db...

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.