Attach Database in SQL Server 2005 with MDF file only

Dear All

Today there was a issue of attaching a database in SQL server 2005
because there was only MDF file was available and no LDF file was there
so if we try to attach the database from GUI interface ( Management Studio )
it won’t allow to add the database and gives errors, so I have executed the system stored procedure to do the task

sp_attach_single_file_db @dbname= ‘databasename’, @physname= ‘C:\Databases\databasefile.mdf’

after executing this command it will show following message

” File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\MSSQL\Data\databasefile_log.ldf” may be incorrect.

New log file ‘C:\Databases\databasefile_log.LDF’ was created.”

And the Database is successfully attached



Prashant Deshpande


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s