Re: Rename File name (logs and mdb)
From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 05/12/04
- Next message: Marcelo: "Stored Procedure"
- Previous message: Joe Celko: "Re: Push in the right direction"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 11 May 2004 20:43:39 -0500
Assuming you want to change the physical file names, you'll need to detach
the database, rename the files and reattach. Of course, the database must
not be in use during this process. For example:
EXEC sp_detach_db 'MyDatabase'
EXEC master..xp_cmdshell 'rename "C:\DataFiles\MyDatabase.mdf"
"MyDatabase1.mdf"'
EXEC master..xp_cmdshell 'rename "C:\LogFiles\MyDatabase_log.LDF"
"MyDatabase_log1.LDF"'
EXEC sp_attach_db 'MyDatabase',
'C:\DataFiles\MyDatabase1.mdf',
'C:\LogFiles\MyDatabase_log1.LDF'
In SQL 2000, you can change logical file names using ALTER DATABASE ...
MODIFY FILE ... NEWNAME.
-- Hope this helps. Dan Guzman SQL Server MVP "martin" <Stuart_REMOVE_36@yahoo.com> wrote in message news:OsTKrf7NEHA.1644@TK2MSFTNGP09.phx.gbl... > Hi, > > Once database has been created is it possible to change the file name of > both the log and data files using an sp. > > may thanks > > martin. > > > > >
- Next message: Marcelo: "Stored Procedure"
- Previous message: Joe Celko: "Re: Push in the right direction"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|