Help needed! database recovery from .mdf (only)

  • Dear All,

    Could anyone help me recover my database from .mdf file only, the problem is I can't attach .mdf in SQL, I've got an error always. second problem is that this mdf file should have 2 log files and both of them are missing, and I can't use "create database from mdf".

    database recovery tools are working fine to view the tables, but to extract the data you have to buy full version which cost really too much.

    if anyone can help me,

    I'll greatly appreciate your help.

    Thank you!

  • Where did you get your mdf from? Was it a clean shutdown?

    If so, you can try sp_attach_single_file_db or CREATE DATABASE [dbname] FOR ATTACH

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

  • What error does it give when you try to attach?

    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
  • this is what I'm trying

    USE [master]

    GO

    CREATE DATABASE [DM_REPO_ERP ] ON

    ( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\DM_REPO_ERP .mdf' ),

    ( FILENAME = N'F:\Temp\DM_REPO_ERP _log.ldf' ),

    ( FILENAME = N'F:\DataBaseLogFiles\DM_REPO_ERP_log.ldf' )

    FOR ATTACH

    GO

    and the Error is this

    Msg 5120, Level 16, State 101, Line 1

    Unable to open the physical file "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\DM_REPO_ERP .mdf". Operating system error 32: "32(failed to retrieve text for this error. Reason: 15105)".

  • Operating system error 32 = The process cannot access the file because it is being used by another process.

    So something else has that mdf file open. Find whatever it is and close or stop it and try again.

    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
  • The log files were deleted accidently, they were on D:\ drive, I've got my mdf file from C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA directory

  • No that file not in use, I have copy of this file on my Desktop

  • vazaryan84 (1/18/2012)


    No that file not in use, I have copy of this file on my Desktop

    The operating system disagrees with you. You reported error 32 from trying to attach. Error 32 means that another process has that file open.

    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
  • Sorry I send wrong one

    here is the error Msg 5173, Level 16, State 2, Line 1

    One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.

    Thank you!

  • Well that's pretty clear...

    vazaryan84 (1/18/2012)


    here is the error Msg 5173, Level 16, State 2, Line 1

    One or more files do not match the primary file of the database. If you are attempting to attach a database, retry the operation with the correct files. If this is an existing database, the file may be corrupted and should be restored from a backup.

    You say the log was deleted, but you have two log files in the list of files you're attaching. Why? Where did they come from?

    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
  • Yea just delete that log file (or move it) and try again.

    I've gotten that error before. Quick easy fix.

  • I was trying to create a log files.

  • vazaryan84 (1/18/2012)


    I was trying to create a log files.

    Well you don't do it like that.

    If you're attaching without a log file, CREATE DATABASE ... FOR ATTACH_REBUILD_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
  • When I do right-click attach database, it comes automaticly with 2 log file names

  • Do those files exist? If not, leave them out and use the command I gave you.

    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

Viewing 15 posts - 1 through 15 (of 18 total)

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