Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 change file name after database creation?

Author  Topic 

nic
Posting Yak Master

209 Posts

Posted - 2004-05-18 : 19:51:02
Hi,
Is there anyway you can change the filename of the data and log files after you have created a database?

I want to create a copy of a pre-existing database. In the past I have copied databases by making a backup, going to the new server, creating a database and restoring the backup into the new database (force the restore). This works well (especially if you need to burn the backup on CD or something). The only problem is the fileName of the datafiles remain the same in the new db.
For example:
original database name: origDB
fileName: origDB_Data
location: \networkPath\origDB_Data.mdf

new database name: newDB
fileName: origDB_Data
location: \networkPath\newDB_Data.mdf

It would be nice if you could rename the fileNames. (This isn't an issue if you keep the database name, but sometimes we will have a production db, and test db. Changing the names would be nice)

Nic

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-05-18 : 20:13:42
I think this is the command:

ALTER DATABASE newDB
MODIFY FILE (NAME = origDB_Data, NEWNAME = newDB_Data)

If not, take a look at ALTER DATABASE MODIFY FILE in SQL Server Books Online.

Tara
Go to Top of Page
   

- Advertisement -