Jump to content

How to get SQL data from .mdf and .ldf files?


Recommended Posts

Hello Experts,

My online database server got crashed.  Fortunatly we recovered the *.mdf and *.ldf files from the crashed hard dick.  
Now I want to restore the database from *.mdf and *.ldf files on new sql server.  
I did below procedure to attache the database from *.mdf and *.ldf files.
I copied the *.mdf and *.ldf files into current sql server data folder and ran the below script. 
=============
use master
exec sp_attach_db 'DB_NAME', 'C:\Program Files\Microsoft SQL Server\MSSQL\Data\DB_NAME.mdf',
'C:\Program Files\Microsoft SQL Server\MSSQL\Data\DB_NAME.ldf'
=============
But i got below error message...
=======================
Server: Msg 9004, Level 21, State 1, Line 1
An error occurred while processing the log for database 'DB_NAME'.
Connection Broken
=======================
Could you please help me with this problem?
Regards!

Link to comment
Share on other sites

Try

exec sp_Attach_Single_File_DB  to attach the MDF file, it will create a new Ldf file.

Also have a look in books online for...
sp_add_log_file_recover_suspect_db

Also have a look this Recommended actions

http://www.karaszi.com/sqlserver/info_corrupt_suspect_db.asp

https://community.office365.com/en-us/f/172/t/266070

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy