0

I want to attach a database to SQL Server 2005 but I have only its .mdf file

How can I attach it?

  • 1
    Depends on whether it was cleanly shut down or not whether or not you can do so without problems. – Martin Smith Sep 25 '12 at 8:32
  • 2
    Have you tried something before asking? Making a quick search using almost same words as your first post is blog.sqlauthority.com/2010/04/26/… – Yaroslav Sep 25 '12 at 8:35
8

E.g like this:

CREATE DATABASE AdventureWorks2012 ON (FILENAME = '{drive}:\{file path}\AdventureWorks2012_Data.mdf') FOR ATTACH_REBUILD_LOG;
|improve this answer|||||
5

Simply,When you attach database, it will display Attach Database dialog box in which click the logfile location and click the remove button. When you click OK, a logfile for you database will be created....

enter image description here

|improve this answer|||||
  • but I dont have a log file to remove.. – user1670625 Sep 25 '12 at 8:54
2

When you attach the mdf via the UI, select the ldf file in the list of files and remove it. A new one will be created.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy