Re: Changing physical file name

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Dinesh T.K (tkdinesh_at_nospam.mail.tkdinesh.com)
Date: 05/12/04


Date: Thu, 13 May 2004 03:01:45 +0530

Simon,

Detach the database using sp_detach_db.Rename the files.Then attach it back
using sp_attach_db mentioning the new names.For syntax 'ndetails for the two
commands, refer BooksOnLine.

--
Dinesh
SQL Server MVP
--
--
SQL Server FAQ at
http://www.tkdinesh.com
"Simon" <me@me.me> wrote in message
news:#GskXRGOEHA.2560@TK2MSFTNGP11.phx.gbl...
>
> I have a database where I'd like to change the physical file name
> of one of it's data files.   The physical file is tied to a filegroup.
>
> It looks something like this
>
> name  fileid  filename                                  filegroup
> FG1  3        c:\mydb_fg1.NDF                   FG1
>
>
> I know I can change the either the name or filegroup using the
following....
>
> alter database mydb MODIFY FILE (NAME = FG1, NEWNAME = NEWFG)
> alter database mydb MODIFY FILEGROUP FG1 NAME = NEWFG
>
> ... but how can I rename the actual filename so it reads as
>
> c:\mydb_newfg.NDF
>
>
> ?
>
>


Relevant Pages

  • Re: How to add FILEGROUP?
    ... > I'm using SQL Server 2000 Standard Edition. ... SE support 32TB per database file, and sum of about 1,000,000 TB totally for the db. ... > If license issue, then how much SQL Server 2000 Standard Edition could cater ... > If filegroup, I had been created some which each one max size is 2GB? ...
    (microsoft.public.sqlserver.server)
  • Re: Backup/restore
    ... is the primary file and that the filegroup is not the primary filegroup? ... DBCC SHRINKFILE (File1, EMPTYFILE) ... ALTER DATABASE MyDB ... Columnist, SQL Server Professional ...
    (microsoft.public.sqlserver.server)
  • Re: Issues with Image data
    ... > What issues arise when considering Backup/Restore and Database recovery. ... That is a killer on disk i/o for SQL Server. ... table on it's own filegroup and then perform filegroup backups and restores. ...
    (microsoft.public.sqlserver.server)
  • Re: How do I shrink my logfile?
    ... the database. ... >> did not know EVERYTHING about SQL Server. ... and that can happen during a restore if you are not ... >> You can only change the physical file names of tempdb. ...
    (microsoft.public.sqlserver.server)
  • Re: File Groups
    ... ALTER DATABASE ... Columnist, SQL Server Professional ... in the filegroup, right?) ... i.e. place it across both drives d and e? ...
    (microsoft.public.sqlserver.server)