Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2004
    Posts
    3

    Unanswered: Database Renaming

    Can anyone suggest a quick and easy way to rename a database AND .MDF/.LDF file in SQL Server?
    I can not, for the life of me, figure out a way to do this.
    Help?

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621
    You could try to backup database and restore it with another name like this (before restoring you may delete old database).

    Old db name is rDB, new will be rrDB.

    RESTORE DATABASE rrDB
    FROM DISK = 'w:\rdb.bak'
    WITH MOVE 'rDB_Data' TO 'w:\rrDB.mdf',
    MOVE 'rDB_Log' TO 'w:\rrDB.ldf'

  3. #3
    Join Date
    Feb 2004
    Location
    Rhode Island
    Posts
    69

    Re: Database Renaming

    Originally posted by JBoyce
    Can anyone suggest a quick and easy way to rename a database AND .MDF/.LDF file in SQL Server?
    I can not, for the life of me, figure out a way to do this.
    Help?
    You can also use sp_renamedb

  4. #4
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: Database Renaming

    Originally posted by smasanam
    You can also use sp_renamedb
    But file names will be the same....

  5. #5
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    "Alter database" has a way to rename logical files, but the physical files will remain the same. If the DB name and the filenames all have to change, then Snail has the right way to go.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •