AdventureWorks is a Sample Database shipped with SQL Server and it can be downloaded from CodePlex site. AdventureWorks has replaced Northwind and Pubs from the sample database in SQL Server 2005.The Microsoft team keeps updating the sample database as they release new versions.
For SQL Server 2012 RTM Samples AdventureWorks Database is released:
You can download either of the datafile and create database using the same. Here is the script which demonstrates how to create sample database in SQL Server 2012.
CREATE DATABASE AdventureWorks2012
ON (FILENAME = 'D:\AdventureWorks2012_Data.mdf')
FOR ATTACH_REBUILD_LOG ;
Please specify your filepath in the filename variable. Here is the link for additional downloads.
Watch a quick video on the same subject.
Reference: Pinal Dave (http://blog.sqlauthority.com)
Hi Pinal,
While trying to attach the file..getting some error…!
I am using CTP3.
CREATE DATABASE AdventureWorks2012
ON (FILENAME = ‘D:\AdventureWorks2012_Data.mdf’)
FOR ATTACH_REBUILD_LOG ;
Can you please suggest how to fix this issue?
Hey Pinal,
Great blog duuuude..How about that picture on the banner..eh?
Can you change it to a recent one from facebook?
Any advise to my issue ?
i’m having difficulty with the path, it’s telling me access denied
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file “C:\Users\Deejay\Downloads\AdventureWorks2012_Data.mdf” failed with the operating system error 5(Access is denied.).
As a few other users have said…. (1) copy the .mdf data file to C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA ……. note that I am running the Express edition on my PC
(2) You have to run sql management studio as Administrator. Right click SSMS and select ‘Run as Administrator’
(3) Open a new query and Use Pinal’s script specifying the “FileName” as your full location path…..in step 1 above
(4) You will get a message as the following but the database will have been created at this point so you don’t need to worry…..File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Log.ldf” may be incorrect.
New log file ‘C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS\MSSQL\DATA\AdventureWorks2012_Data_log.ldf’ was created.
Converting database ‘AdventureWorks2012′ from version 705 to the current version 706.
Database ‘AdventureWorks2012′ running the upgrade step from version 705 to version 706.
I hope this helps you.
This helped me too.
Thanks a lot.
This helped too…
Thanks
Make sure that if u running SQL Server Service under NT Service\MSSQLSERVER, that same user has access to the folder where your .mdf files are.
Works for me. Thanks a lot!!! Funcionó de 10!! Muchas Gracias!!!
Thanks alot Tresor.. you saved my day..
Thanks a lot!!!!
Thanks Tresor..It worked!!
:)
Hi dee,
You have to run sql management studio as Administrator.
Best Regards,
Damodar
Thank you, Damodar. Solved my problem here.
Pingback: SQL SERVER – Installing AdventureWorks Sample Database – SQL in Sixty Seconds #010 – Video « SQL Server Journey with SQL Authority
The script worked for me. Although I got the following message:
Converting database ‘AdventureWorks2012′ from version 705 to the current version 706.
Database ‘AdventureWorks2012′ running the upgrade step from version 705 to version 706.
Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database ‘AdventureWorks2012′ cannot be opened because it is version 705. This server supports version 655 and earlier. A downgrade path is not supported.
– i have SQL server 2012 express. I get teh same error when i try to attach it from the UI.
I Get the same Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database ‘AdventureWorks2012′ cannot be opened because it is version 705. This server supports version 663 and earlier. A downgrade path is not supported.
i’m having difficulty with the Access, it’s telling me access denied
Run sql management studio as Administrator. But no use.
Msg 5120, Level 16, State 101, Line 4
Unable to open the physical file “C:\DB\AdventureWorks2012_Data.mdf”. Operating system error 5: “5(Access is denied.)”.
Same issue with me
like always it was exactly what i needed. thanks!
I worked for me, just need to copy the data file to the data path (C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA) and run the Management Studio as Administrator.
For those having Access is Denied issues try the following:
Right click the mdf file > Security > Edit > Owner Rights: Full Control > Apply > OK > Apply > OK.
Anybody face this error ?
—————
Could not continue scan with NOLOCK due to data movement.
Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted. (Microsoft SQL Server, Error: 601)
————-
(Already build ldf)
I think it is due to either your database is offline, or the server connectivity got down
The AdventureWorks database simply does not work! Using full admin permissions doesn’t work either. It was simply shipped “f’d” up!
Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database ‘AdventureWorks2012′ cannot be opened because it is version 705. This server supports version 655 and earlier. A downgrade path is not supported.
I faced the same issue but i had not installed 2012 RTM.
–>First make sure that you have installed sql server 2012 RTM.
–>Then, Like peizhen said just copy the AdventureWorks2012_Data.mdf to (C:\ProgramFiles\MicrosoftSQLServer\MSSQL11.MSSQLSERVER\MSSQL\DATA) and run the Management Studio as Administrator.
Hope this helps…
It means you are trying to restore the database with higher version to the lower versioned server
Please help with this error!
Thanks for this blog entry Pinal. It was a big help!
hello sir, i am a beginner for sql server…please tell me from where i can learn it and which platform will be better to learn it. please guide me …thank you
If you’re using sqlserver 2008r2 download the 2008R2 compatible file instead ==> http://msftdbprodsamples.codeplex.com/releases/view/59211
I am using MS SQL Server 2012 Express and this work. Just make sure you put the right path, the file in the right folder and in the right instance if you have several instances. In addition, run the database as Administrator.
Pingback: Spreadsheets Made Easy - Practical information and tutorials on spreadsheets.
It works……..Thanks
Thank you! Newbie to sql.
Awesome Blog!!! I was having the hardest time! Thank you!!!
it works… if you have access issue… you need to copy the database to data folder….. Thanks.
Anyone tried installing SQL Server 2008 or 2012 Enterprise trial onto Windows 7 Home Premium? I see no documentation that it is supported or not supported, but having many problems.
guys, actually I’m having trouble attaching the 2012 databases using the above create/attach script. Anyone tried on a Windows 7 Home Premium OS?
I made sure to install every available feature of SQL Server 2012, downloaded the AdventureWorks 2012 database to C: , opened SQL Server Studio as Administrator, and ran create/attach script. I keep getting File activation failure. The physical file name “C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\DATA\AdventureWorks2012_Log.ldf” may be incorrect.
Msg 5123, Level 16, State 1, Line 1
CREATE FILE encountered operating system error 5(Access is denied.) while attempting to open or create the physical file ‘C:\AdventureWorks2012_log.ldf’.
Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted.
Based on Pinal’s example, the .mdf file doesn’t need to be in any specific folder, as long as I use the correct path in the create/attach script.
Please, any advice?
I also have a copy of this .mdf file in my Downloads folder. If I run this:
CREATE DATABASE AdventureWorks2012
ON (FILENAME = ‘C:\Users\Aitch\Downloads\AdventureWorks2012_Data.mdf’)
FOR ATTACH_REBUILD_LOG ;
I get the following error:
Msg 5133, Level 16, State 1, Line 1
Directory lookup for the file “C:\Users\Aitch\Downloads\AdventureWorks2012_Data.mdf” failed with the operating system error 5(Access is denied.).
I keep gettin this error …. Tried all sorts of things, none worked.
Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database ‘AdventureWorks2012′ cannot be opened because it is version 706. This server supports version 655 and earlier. A downgrade path is not supported.
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “c:\AdventureWorks2012_Data.mdf”. Operating system error 2: “2(The system cannot find the file specified.)”.
I have this Error the file in c
I am also getting this error[Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “c:\AdventureWorks2012_Data.mdf”. Operating system error 2: “2(The system cannot find the file specified.)”.], can somebody help us out here??
1. made sure admin and logon user has full control on directory, Tried from custom folder and also from C:\ SQL path
2. Try to attach through IDE, same error..
thanks in advance,
HydTechie
running the SQL management console as “administrator’ fixed the Operating system error 5: “5(Access is denied.)” issue .. Thank you all
Worked for me. Excellent. I ran SSMS aas administrator.
Nice post.It works well.thanks.
this isn’t working…help
while (dataReader.Read())
{
int departmentId = dataReader.GetInt32(0);
string Name = dataReader.GetString(1);
string GroupName = dataReader.GetString(2);
Console.WriteLine(
“DepartmentID: {0}\nID: {1}\n{2}\n”, Name, GroupName);
}
Msg 1813, Level 16, State 2, Line 2
Could not open new database ‘MyAdventureWorks’. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 2
The database ‘MyAdventureWorks’ cannot be opened because it is version 661. This server supports version 655 and earlier. A downgrade path is not supported.
Pingback: SQL SERVER – Restoring 2012 Database to 2008 or 2005 Version and 2 other Most Asked Questions « SQL Server Journey with SQL Authority
Now you have help me again,again and again on so many questions about SQL-Server. Now and here a gread THANKS!!!!!! for your work. J.M.-S.
What a great post, thanks Pinal
I copied file path of exact location of .mdf folder, Operating System error 2?
Can you please explain.
Thanks
Chalrotte
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “C:\Program Files\Microsoft SQL Server\MSSQL11.MSSQLSERVER\MSSQL\SQLDATA\AdventureWorks2012_Data.mdf”. Operating system error 2: “2(The system cannot find the file specified.)”.
Make sure you have all needed permission or the file actually exist
Hi Pinal Dave,
You are rocking… Ur blogs help me to resolve so many work place issues. Great. I have a query regarding Adventure works project. Does it comes with UI ? I mean front end as well ? I need a sample application which uses MS SQL to understand. Any pointers to this is really appreciated.
Thanks again for great blogs :)
Just add full permission to your domain account on the directory where the MDF file exists
I’m getting an incorrect syntax error on ‘FOR ATTACH_REBUILD_LOG’;
It states it’s expecting an ‘ID’. What ID ?
Help! I’m a REAL novice at this.
Pingback: SQL SERVER – Weekly Series – Memory Lane – #020 | SQL Server Journey with SQL Authority
Thank you very much for you instruction :)
Thank you very much for this extremely helpful post! I encountered only 2 issues which I quickly figured out. The first was the script failed the first time I ran it because it said I did not have permissions; so I had to go to the data file I downloaded, right click on it, go to Properties>Permissions and give myself Full Control. I then re-ran script and got the desired results that matched what you show. Second, maybe just because I was tired, I didn’t see the AdventureWorks database automatically appear in my SQL Management Studio window as you show – then realized I had not connected to it. Once I did, and selected the database, all was good. These might be trivial for experienced SQL users, but wanted to pass along for any other amateurs like me :) Thanks again – great job and VERY helpful!!!
i down loaded the adventureworks 2012 for sql 2012 FROM your link but humanresources.employee table is not giving me the the table with employeeid, managerid and so on. instead it gives me businessEntityID, MARITAL STATUS, GENDER, BIRTHDATE, HIREDATE etc etc… i don’t know if i downloaded something wrong.
I have created a cube in SSSAS. And Now I want to create reporrt using that cube.
In report I have to create cascading parameters (Example: I have two parameter country and city.
So If I select country then their respective Citys should come in City parameter )
So any one of you could you please let me know that How Can I create cacscading parameter?
Should I create some hierarchy in SSAS?
Or I have to do something at report level ??
Pinal, your instructions are of less value by your not dealing with the common permission and connection issues that people face when downloading and trying to install. Further, your narrative presentation leaves much to be desired, at least for English-speaking citizens of the U.S. . I understand your ‘English’ ; but bad diction, pronunciation, and obfuscating accent are not helpful. You perhaps would do somewhat better if you limited yourself to writing only the script for narration; but as someone who speaks, reads; writes three languages(including English); and knowing some vocabulary in Hindi, Urdu, and Punjabi; I would not attempt to give a presentation in Hindi of even something as simple as this is technically; that was full of mispronunciations, mixing of tenses, bad sentence construction, and misspellings…Other than that; I appreciate your efforts…
Hi Ted,
Thanks for your feedback.
Hi Pinal,
Thank You! The notice of the upgrade of Adventure Works is welcome news to those developers among us who are looking to create great templates for MVC4, EF5, HTML5, CSS3 sites with services and I continue to be a grateful follower of your insights into the SQL Server world!
I still have this error:
Msg 1813, Level 16, State 2, Line 1
Could not open new database ‘AdventureWorks2012′. CREATE DATABASE is aborted.
Msg 948, Level 20, State 1, Line 1
The database ‘AdventureWorks2012′ cannot be opened because it is version 706. This server supports version 662 and earlier. A downgrade path is not supported.
hi pinal , i am getting this error can u give me reply for this error I would be grateful to you
Msg 5120, Level 16, State 101, Line 1
Unable to open the physical file “E:\AdventureWorksDW2012_Data”. Operating system error 2: “2(The system cannot find the file specified.)”.