# Database Discussions > Microsoft SQL Server 2008 >  Is there a method to recover corrupted .ldf file?

## bastiengrandis

hello folks,

I have a mdf file and ldf file from a hard drive that was corrupted... it appears that corruption caused problems with the ldf file. During an attach command SQL Server I get the following error: "Error 823: I/O error 38(reached the end of the file.) ..... on the LOG.ldf file"

Guys, any help, I'll be appreciated!

----------


## rmiao

Tried attach .mdf file only with sp_attach_single_file_db?

----------


## georgecochet

Restore With Transact-SQL

-Click New Query in the Management Studios main toolbar. This opens a large text area on the right side of the screen.

-Click in the text area and type a Create Database statement using the following Transact-SQL code as a guide:
CREATE DATABASE MyDatabase ON (FILENAME = 'c:\data files\my_data.mdf'), (FILENAME = ' c:\data files\my_data.ldf') FOR ATTACH;

-Click the Execute button in the Transact-SQL toolbar, located just under the Management Studios main toolbar. The Execute button symbol is a right-pointing triangle. SQL Server Management Studio restores the database.

Helpful resources to explain another methods of restoration and gave more variants of sql data recovery...

https://social.technet.microsoft.com...ssdsgetstarted
http://www.filerepairforum.com/forum...on-on-sql-2014
http://www.sqlserver.repairtoolbox.com/ SQL Server Repair Toolbox

----------


## ted

Run Chkdsk to find the issue with system inconsistency. You can attach .MDF file without transaction log file (.ldf). 
You can consider below article for details:  

http://sql-server-recovery.blogspot....base-with.html

----------

