Nantz1 on Sun, 21 Oct 2012 23:50:49
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.
Mr. Wharty on Mon, 22 Oct 2012 00:20:01
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.
- Highligh the log file entry
- Click on the Remove Button
G3rb on Tue, 29 Oct 2013 16:09:00
This does not work on SQL Server 2012 on Windows Server 2012. Any ideas?
Tom Phillips on Tue, 29 Oct 2013 16:12:02
Please follow the installation instructions found here:
Gary S Wood on Thu, 27 Feb 2014 03:50:40
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?
Aditya Rathi on Mon, 10 Mar 2014 06:56:52
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./
Aditya Rathi on Mon, 10 Mar 2014 07:08:58
See the above example; and Edit the name and location of the File
CREATE DATABASE AdventureWorks2012 ON (name = 'AdventureWorks2012_data', filename = 'drive:\path\AdventureWorks2012_Data.mdf') FOR ATTACH_REBUILD_LOG;
rajeevkr72 on Fri, 21 Jul 2017 11:38:47
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.
shreeharshas on Mon, 20 Nov 2017 08:17:44
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!