The tip shows how to attach AdventureWorksDW2012 database on SQL Server 2012
Where to Downlaod
It downloads AdventureWorksDW2012.zip file to downloads folder. If you extract the zip file, it creates two files(AdventureWorksDW2012_Data and AdventureWorksDW2012_log).
Installation:
Copy the extracted two files(AdventureWorksDW2012_Data and AdventureWorksDW2012_log) to C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\ (verify the path your instance might be different)
Attach AdventureWorksDW2012 to SQL Server:
SQL Server Instance > DataBases Right Click > Attach... > select MDF file from C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\AdventureWorksDW2012_Data.mdf. > OK > it creates AdventureWorksDW2012 under databases
Using SQL:
USE [master]
GO
CREATE DATABASE AdventureWorksDW2012 ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\\AdventureWorksDW2012_Data.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\\AdventureWorksDW2012_log.ldf' )
FOR ATTACH ;
GO
Error:
While attaching database, If you any get any error like "The file "../AdventureWorksDW2012_Data.mdf" is compressed but does not reside in a read-only database or filegroup. The file must be decompressed." Do the following resolution.
Navigate to C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER2012\MSSQL\DATA\ > Right click on AdventureWorksDW2012_Data.mdf file > Click “Properties” > Click “Advanced...” > Uncheck “Compress contents to save disk space” > OK