SQL Server Performance Forum – Threads Archive
Modify Database Operating System File NameHow to change database operating system file name through T-SQL command? For example, I want to change the below data file name from "FILENAME = ‘MataMSSQL.1MSSQLDataSAMPLEDB08242006_data.mdf’" to FILENAME = ‘MataMSSQL.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 = ‘MataMSSQL.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
ALTER DATABASE FOO
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.
SQL-Server-Performance.com All in Love is Fair
All postings are provided â€œAS ISâ€ with no warranties for accuracy.
ALTER DATABASE Foo
MODIFY FILE ( NAME = FooBar_Data, FILENAME = ‘ new_path/os_file_name ‘ )
All of this is still in Books Online…