Take the 2-minute tour ×

I have SQL Server 2008 R2, and I need to restore my database to another server but backup.ldf file has been corrupted, so is it possible to restore my database using just the .mdf file alone? Or is there any possibilities for creating the .ldf file manually?

share|improve this question
Good question. I would like to know the answer myself! Why not try it out? Copy the .mdf into the data directory of your MSSQL server and connect it in SSMS. As far as I understand it the .ldf file holds information relating to open transactions. So this information will not be available when you set up the new database. -- OK, I think @Alex K. 's solution is to be preferred! ;-) –  cars10 Aug 5 '13 at 12:37
YMMV sp_attach_single_file_db –  Alex K. Aug 5 '13 at 12:38
i tried USE [master] GO -- Method 1: I use this method EXEC sp_attach_single_file_db @dbname='TestDb', @physname=N'C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\TestDb.mdf' GO –  ibu Aug 5 '13 at 12:40

1 Answer 1

You can try attaching the MDF by right clicking on databases in SSMS, and deleting the reference to the log file location in that dialog, and a new one will be created, assuming the MDF is not corrupt.

share|improve this answer
I already tried by removing the ldf file,but File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\DATA\DCFHO_log.ldf" may be incorrect. The log cannot be rebuilt because there were open transactions/users when the database was shutdown, no checkpoint occurred to the database, or the database was read-only. This error could occur if the transaction log file was manually deleted or lost due to a hardware or environment failure. Msg 1813, Level 16, State 2, Line 1 Could not open new database 'TestDb'. CREATE DATABASE is aborted. –  ibu Aug 5 '13 at 12:49
its possible to recreate ldf file –  ibu Aug 5 '13 at 12:56

Your Answer


