Re: Rename File name (logs and mdb)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Dan Guzman (danguzman_at_nospam-earthlink.net)
Date: 05/12/04


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.
>
>
>
>
>


Relevant Pages

  • Re: Change Field Name in Table
    ... try to figure out the delete and/or renaming it again. ... table with the make Table query or even using the DoCmd Copy. ... move everything over to another database and use the new database. ... was Imported and you should be able to rename it. ...
    (microsoft.public.access.formscoding)
  • Re: Security Wizard
    ... you can't just rename/delete all existing mdw files. ... If you found system.mdw and renamed it, just rename it back to system.mdw and try and open Access. ... Accounts and Encrypt/Decrypt the database. ... Security Wizard at this time': ...
    (microsoft.public.access.gettingstarted)
  • Re: ESENT Event ID 474 Database page cache error
    ... As your server is freezing this usually means hardware so check all your ... Resetting the FRS database with the following steps: ... Rename the ntfrs.jdb file in the \ntfrs\jet folder. ...
    (microsoft.public.windows.server.sbs)
  • Re: Deleting Multiple Rows
    ... WHERE [SomeInt] IN ... > in the database then do it there. ... > EXEC usp_deletex '1,2,3' ... > SQL Server MVP ...
    (microsoft.public.sqlserver.programming)
  • Re: Cant Rename Form in AC 2007
    ... I was able to rename it after I rebooted. ... Look at the Has Module property ) If it is No, this suggestion won't help. ... Make a backup copy of your database, ... In the code window, Select all from this window Open a copy of notepad, paste the code in, and save it as a text file. ...
    (microsoft.public.access.forms)