I am planning to rename the data files using the steps outlined below...Could you let me know if that is the standard way of doing it on 2005? Database name- testdatabase Datafiles- testdatabase_1.mdf , testdatabase_2.ndf , testdatabase_3.ldf I need to rename the physical files to testdatabase_data.mdf , testdatabase_sec.ndf , testdatabase_log.ldf Steps: 1) Take the database offline 2) Rename the actual physical files from testdatabase_1.mdf , testdatabase_2.ndf , testdatabase_3.ldf to testdatabase_data.mdf , testdatabase_sec.ndf , testdatabase_log.ldf 3) Run the following commands to update the file names in sysdatabases Alter database testdatabasr Modify file (name=Testdatabase_Data,filename= 'G:MSSQLData' testdatabase_data.mdf ') Alter database FlatironsDSL Modify file (name=SECONDARY,filename= 'G:MSSQLData'testdatabase_sec.ndf' ) Alter database FlatironsDSL Modify file (name=Testdatabase_log,filename= 'G:MSSQLData'testdatabase_log.ldf) 4) execute sp_helpdb <dbname> to ensure tha new file names are updated 5) Bring the database online This works on my test server.But i thought of confirming this before I do this on the production box. I need to do this to comply to naming conventions. Let me know if there is an alternate way to do this.
As you are prepared for a downtime on the database, best way is to detach the databses rename the physical name of the files and reattach again. Detach - SP_DETACH_DB Attach - SP_ATTACH_DB For more information and code examples for these SPs refer to Books online (updated0.
Hi Satya, I tried that. - Detach the DB - Renamed the physical files - Attach it back This fails because the sysdatabases still holds the old file names.The database fails to start up because the old files are no longer there (i renamed it) Thanks!!
Hi Sathya , Reattaching the database was failing when I tried it from the GUI.But when I tried it using the commands, it worked...Thinking about it....what goes on at the back is the same as the initial steps I outlined in the initial post... Does renaming the data file cause the database to go corrupt at any stage
Thats why I have referred to do with TSQL [] and in addition to that for reference on your first post linked the relevant KBA. As far as your other question is concerned, not at all. If you have attached the DB successful and see no warnings or errors on the log... good to go.
Nice suggestion Satya, kind of forgot about attach and deattach...porbably thats why you are GURU [] Regards Sat