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)
 Rename database file

Author  Topic 

delpiero
Yak Posting Veteran

98 Posts

Posted - 2005-05-09 : 21:53:42
Hi all,

Is there any quick way to rename a database file on the OS level? I could do that by copying databases, but I would like to know if there is any quick command which can rename the physical file name either online or offline.

Thanks,
delpiero

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-05-09 : 22:29:17
From Books Online:

quote:

ALTER DATABASE database
{ ADD FILE < filespec > [ ,...n ] [ TO FILEGROUP filegroup_name ]
| ADD LOG FILE < filespec > [ ,...n ]
| REMOVE FILE logical_file_name
| ADD FILEGROUP filegroup_name
| REMOVE FILEGROUP filegroup_name
| MODIFY FILE < filespec >
| MODIFY NAME = new_dbname
| MODIFY FILEGROUP filegroup_name {filegroup_property | NAME = new_filegroup_name }
| SET < optionspec > [ ,...n ] [ WITH < termination > ]
| COLLATE < collation_name >
}

< filespec > ::=

( NAME = logical_file_name
[ , NEWNAME = new_logical_name ]
[ , FILENAME = 'os_file_name' ]
[ , SIZE = size ]
[ , MAXSIZE = { max_size | UNLIMITED } ]
[ , FILEGROWTH = growth_increment ] )



Pay attention to the 'os_file_name' piece.

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

delpiero
Yak Posting Veteran

98 Posts

Posted - 2005-06-13 : 03:14:49
Sorry to come back to this topic so late. I also found the following in Books Online at the same time:

" FILENAME can be specified only for files in the tempdb database, and the new name does not take effect until Microsoft SQL Server is restarted."

Thatz why I couldn't rename the physical file name using this ALTER DATABASE command. I want to move the physical data and log files for the msdb and model databases to another location. How do you usually accomplish that?

Thanks,
delpiero

Go to Top of Page

delpiero
Yak Posting Veteran

98 Posts

Posted - 2005-06-13 : 03:30:32
Oh, I found the following article which describes the procedures to relocate the msdb and model files. Sorry to bother.

http://support.microsoft.com/default.aspx?scid=kb;en-us;224071#XSLTH3157121122120121120120

Thanks,
delpiero
Go to Top of Page
   

- Advertisement -