Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 rename a database is possible?

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2006-11-16 : 05:28:51
Dear friends, is it possible to rename a Database?







thank you very much.

Vinod

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-11-16 : 05:30:14
Yes, very much possible

EXEC sp_dboption 'OldName', 'Single User', 'TRUE'
EXEC sp_renamedb 'OldName', 'NewName'
EXEC sp_dboption 'NewName', 'Single User', 'FALSE'


Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-11-16 : 05:41:35
And you need to make sure that it doesnt affect the applications which use that database

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-16 : 13:16:03
sp_renamedb will leave the Logical names of the database files as they were - which were probably based on the name of the original database, and thus likely to add to confusion in the future!

Kristen
Go to Top of Page

DMcCallie
Yak Posting Veteran

62 Posts

Posted - 2006-11-16 : 14:21:30
1. Detach using EM
2. Rename the .mdf and .ldf to avoid confusion.
3. Attach the DB using EM (specify the newly renamed .mdf and .ldf containers as well as a new name for the DB)

That's it!

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2006-11-16 : 15:29:01
"That's it!"

Won't change the logical names though ...
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2006-11-17 : 06:04:34
Great support thank you friends

Vinod
Go to Top of Page
   

- Advertisement -