Link to home
Start Free TrialLog in
Avatar of bibi92
bibi92Flag for France

asked on

rename datafile sqlserver


How can I rename a logical name and datafile name like D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\test\db_File.mdf or D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\test\db_File1.mdf




Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You can not Rename logical name and datafile name.
The following steps will allow you to 'rename' the data files.

1.  Bring your current database 'OFFLINE'
2.  Create a new database with the desired logical names (this will create the new desired filenames as well)
3.  Bring your newley created databae 'OFFLINE' as well
4.  Navigate to the directories where the data files are stored for the NEW database and delete them.
5.  Copy the data files from the OLD database and rename them to the ones you just deleted.
6.  Bring you NEW database online and your good to go.

Please note if you plan on KEEPING the name of the old database you'll need to right click the old database that is listed and click 'rename' (maybe add _save to the database name) BEFORE you bring it OFFLINE.
Yes, You can not Rename logical name and datafile name. You can restore it to a new DB with other name.
Avatar of bibi92


Thanks bibi