November 2, 2006 at 8:59 am
How do I change the name of an existing database?
SQL Server 2000
November 2, 2006 at 9:09 am
exec sp_renamedb 'oldname', 'newname'
November 2, 2006 at 9:17 am
Thank you,
Do i have to do anything with the .mdf, .ndf or .ldf?
November 2, 2006 at 9:24 am
not required
-------------------------------------------------
-Amit
Give a man a fish and he'll ask for a lemon. Teach a man to fish and he wont get paged on weekends !! :w00t: - desparately trying to fish [/size]
November 2, 2006 at 9:25 am
No, if you want to change 'em along with the database name you need to run a separate command.
Check out "ALTER DATABASE" in the books online.
modify filename section.
November 2, 2006 at 10:23 am
I put a script in the library here about two weeks ago that was named "Switch_Database.sql", and it does it all... It was designed to allow a snapshot to be generated and completely ready to be used before the name change. It changes the DB name, the logical name(s), and the physical file name(s)... and takes less than 20 seconds to do it all... it puts the DB into single user mode - so kicks off connections that will have to be reconnected; but that should be understandable. There are comments in the file. You might take a look. It gets awfully confusing if you don't change everything together... and if you end up changing it more than once, or many times, it gets even harder when the logical and physical names aren't changed each time.
Thank-you,
David Russell
Any Cloud, Any Database, Oracle since 1982
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply