Restoring db

  • Hi,

    Is it able to restore a database from just mdf file.

    I dont have the ldf file..

    Wat can I do?

    Thanks,

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

  • The MDF is the data file, not a backup file. I'm guessing you're trying to see if you can reattach the database with just the MDF file?

    Take a look here:

    http://msdn.microsoft.com/en-us/library/ms174385.aspx

    If this works, a new LDF file should be created when you re-attach the database.

  • You might be able to attach it. If the database was shut down cleanly, then in the process of attaching, SQL will create a new ldf. If the database was not shut down cleanly, the attach will fail.

    No chance of getting an actual backup?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • @ blackbird

    Ya,i want to reattach the database with just MDF file.

    @ gilamonster

    That server was made to shut down and the images of the databases were taken, now wen we are extracting from the images, we can find only the mdf files.

    Regards
    Sushant Kumar
    MCTS,MCP

  • Did you take a full backup before shutting down ? That's always a good idea to do before making changes to databases, servers, configuration etc ... Then you could do a restore which will include the .ldf

  • You can try to attach it, you'll just have to remove the reference to the ldf file in the attach dialog. If the image was made while SQL was running it probably won't attach. If that happens, see this blog post for a method of hacking and repairing the DB - http://sqlinthewild.co.za/index.php/2009/06/09/deleting-the-transaction-log/

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • try this.

    EXEC sp_attach_single_file_db @dbname = '', --- your database name

    @physname = '' --- the location of the .mdf file

  • Ya, it works.

  • Ya, it worked.

    Thanks all

    Sushant

    Regards
    Sushant Kumar
    MCTS,MCP

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply