Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2005
    Posts
    2

    Unanswered: restore database without mdf or ldf file

    Hi,

    Is it possible to restore a database with only a .bak file??
    When I try to restore the system comes up with 2 paths where probably the original .mdf and .ldf files existed, but on my system they don't exist. How can I avoid this problem? (it's not possible to get the ldf and mdf files anymore...)

    Grtz
    Carlos

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    create a new database like so...

    CREATE DATABASE MyDATABASE

    use sp_helpdb to get the filenames for the mdf and the ldf you just created

    sp_helpdb MYDATABASE

    use RESTORE FILELISTONLY to get the logical filenames of the mdf and ldf in the backup file like

    RESTORE FILELISTONLY
    FROM DISK = 'C:\Mybackup.bak'

    Use RESTORE with MOVE like so

    RESTORE DATABASE MyDatabase
    FROM DISK = 'C:\Mybackup.bak'
    WITH REPLACE,RECOVERY,
    MOVE 'Logicalfile_Data' TO 'D:\Microsoft SQL Server\MSSQL\data\physicalfile.mdf' , MOVE 'Logicalfile_Log' TO 'D:\Microsoft SQL Server\MSSQL\data\physicalfile_log.LDF'
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Jan 2003
    Location
    India
    Posts
    523
    Its quite possible to restore the db even if the underlying db is not preset. U need to provide the correct path where u want the mdf and ldf files to be created.

  4. #4
    Join Date
    Dec 2005
    Posts
    2

    Re

    Thnx for the quick reply!

Posting Permissions

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