Restore MDF file without LDF file

1 ) Use this statement to create new log file.

sp_attach_single_file_db @dbname = ‘testcrashdb’
, @physname = ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\testcrashdb.mdf’

Message :File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\testcrashdb_log.ldf” may be incorrect.
New log file ‘C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA\testcrashdb_log.LDF’ was created.

2 ) Then attach the mdf and ldf file to restore db

USE [master]
CREATE DATABASE [testcrashdb] ON
( FILENAME = N’C:\Program Files\location of mdf file\testcrashdb.mdf’ ),
( FILENAME = N’C:\Program Files\location of log file\testcrashdb_log.ldf’ )


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s