Modify Database Operating System File Name | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Modify Database Operating System File Name

How to change database operating system file name through T-SQL command? For example, I want to change the below data file name from "FILENAME = ‘M:DataMSSQL.1MSSQLDataSAMPLEDB08242006_data.mdf’" to FILENAME = ‘M:DataMSSQL.1MSSQLDataSAMPLEDB08242006_data_2.mdf’. I greatly appreciate if anyone can help me on this. Thanks, Bhushan ————————————————————————– Ilustration: USE MASTER GO CREATE DATABASE SAMPLEDB08242006 ON ( NAME = SAMPLEDB08242006_DATA, FILENAME = ‘M:DataMSSQL.1MSSQLDataSAMPLEDB08242006_data.mdf’, SIZE = 30, MAXSIZE = 100, FILEGROWTH = 5 ) LOG ON ( NAME = SAMPLEDB08242006_LOG, FILENAME = ‘N:LogsSAMPLEDB08242006_LOG.LDF’, SIZE = 10, MAXSIZE = 25, FILEGROWTH = 1 ) GO

MODIFY FILE ( NAME = FooBar_Data, NEWNAME = ‘X:MSSQLDataFooBar_Data.mdf’)
This is all in Books Online….

Thank YOU for reply. The script is execute sucessfuly and updated in database properties but the physical file name is not changed in the server. I wanted to change physical file name not the logical file name.. any help is greatly apprecaited. Bhushan Kalla
You can backup database, the restore and change physical in move tab.
Luis Martin
Moderator All in Love is Fair
Stevie Wonder
All postings are provided “AS IS” with no warranties for accuracy.
MODIFY FILE ( NAME = FooBar_Data, FILENAME = ‘ new_path/os_file_name ‘ )
All of this is still in Books Online…