Tuesday, January 26, 2010

AdventureWorks2008

If you are preparing for the 70-433 exam AND you're using Microsoft SQL Server 2008 - Database Development Self Paced Training Kit AND you're running a full version of SQL 2008...

When you attempt to attached the AdventureWorks2008.mdf (page xx in the book) you will run into "SQL Server Error: 5120". The work around is to execute the following script in SQL Server Manager;

Note: Be sure to change the pathing to point to the location of the files on your system.

USE [master]
GO
CREATE DATABASE [AdventureWorks2008] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\AdventureWorks2008_Data.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\AdventureWorks2008_Log.ldf' ),
FILEGROUP Documents CONTAINS FILESTREAM (NAME = Documents, FILENAME=N'C:\Program Files\Microsoft SQL Server\MSSQL10.SQL2008\MSSQL\DATA\Documents')
FOR ATTACH
GO

Anyone with the technical explantion of why, please comment for the benefit of the community.

Thanks to
http://geekswithblogs.net/influent1/archive/2009/06/09/132711.aspx for this solution.