Where do I get the AdventureWorks log file? Getting error when attaching AW .mdf file. Says "error .ldf log file not found" RRS feed

  • Question

  • Where do I get the AdventureWorks log file? Getting error when attaching AW .mdf file. Says "error .ldf log file not found"

    I figured I would just copy one of the other .ldf files, tempdb_log.ldf, but I keep getting an "file in use" error.

    Thank you,


    Sunday, October 21, 2012 11:50 PM


All replies

  • You don't need the log file as it will be created when the database is attached.  Just delete the log file entry from the Attach Database screen before attaching the database.

    1. Highligh the log file entry
    2. Click on the Remove Button

    When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer

    Jeff Wharton
    MSysDev (C.Sturt), MDbDsgnMgt (C.Sturt), MCT, MCPD, MCSD, MCITP, MCDBA
    Blog: Mr. Wharty's Ramblings
    Twitter: @Mr_Wharty
    MC ID: Microsoft Transcript

    • Proposed as answer by Olaf HelperMVP Monday, October 22, 2012 5:36 AM
    • Marked as answer by Mr. Wharty Thursday, January 3, 2013 12:03 AM
    Monday, October 22, 2012 12:20 AM
  • This does not work on SQL Server 2012 on Windows Server 2012. Any ideas?
    Tuesday, October 29, 2013 4:09 PM
    • Proposed as answer by Mr. Wharty Friday, November 1, 2013 5:30 AM
    • Marked as answer by Mr. Wharty Friday, November 1, 2013 5:30 AM
    Tuesday, October 29, 2013 4:12 PM
  • This did also not work for me.  I ended up using the scripted "Add Database" solution.  It also failed initially until I moved the Adventureworks MDF to the default data location for SQL server and tried it again.  Doesn't like users being creative with file paths?
    Thursday, February 27, 2014 3:50 AM
  • Write a SQL command to create Database with Log file.

    Give the Location and name of the already existing .MDF file.

    Give  a filename and location for that log file.

    It will Create a Log File dynamically for the .MDF file./

    Monday, March 10, 2014 6:56 AM
  • CREATE DATABASE AdventureWorks2012
      ON (name = 'AdventureWorks2012_data', 
      filename = 'drive:\path\AdventureWorks2012_Data.mdf')
    See the above example;  and Edit the name and location of the File
    • Proposed as answer by rajeevkr72 Friday, July 21, 2017 11:33 AM
    Monday, March 10, 2014 7:08 AM
  • Also go to the directory where the data file is copied and right click on the file and click on Unblock button. Normally files are blocked when it is copied from an external site. After that use the script or attach option to create the database. You may also provide full permission to the users of the computer to this particular data file (Right click on the file > Security > Select "users" > Provide full permission). I did this 2 steps and it worked for me.

    • Edited by rajeevkr72 Friday, July 21, 2017 11:40 AM
    Friday, July 21, 2017 11:38 AM
  • I got it working. The mdf file I downloaded from Microsoft site was enough.

    1. Unblocked the mdf

    2. Moved the mdf to C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\

    3. Opened SQL Server and ran the command:

    EXEC sp_attach_single_file_db @dbname = 'AdventureWorksDW2012',@physname = N'C:\Program Files\Microsoft SQL Server\MSSQL12.SQLEXPRESS\MSSQL\DATA\AdventureWorksDW2012_Data.mdf'

    4. Got below output, disconnected and reconnected to SQL Server and voila!

    MDF without LDF command

    Computer is a box with magic called software.

    Monday, November 20, 2017 8:17 AM
  • Thank you for this!
    Wednesday, June 27, 2018 12:10 AM
  • Download AdventureWorks2012_Data.mdf from Microsoft and copy it on C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA . Then in SQL Server Attach->Add it from C:\ part not D:\ it also works.


    Friday, January 25, 2019 10:48 AM