Click here to Skip to main content
15,866,422 members
Articles / Database Development / SQL Server / SQL Server 2008

HowTo: Install the Northwind and Pubs Sample Databases in SQL Server 2008 Express

Rate me:
Please Sign up or sign in to vote.
4.95/5 (44 votes)
18 Oct 2013CPOL6 min read 347.2K   22.4K   50   59
To save you from hunting through the docs and locating downloads, we gather both databases here and walk you through installing them using SQL Server Management Studio Express -- updated for SQL Server 2008 Express Edition!
Note: SQL Server 2005 Users Click Here for the SQL Server 2005 version of this article

Introduction

The Northwind and Pubs sample databases are staples of other sample code on this and other development websites. They are used in countless tutorials and walkthroughs published by Microsoft and others. Being a SQL/SQL Server newbie myself, I figured there may be others in my boat who might want both databases in an easily-accessible spot, and an easier, less error-prone way of installing them into SQL Server 2008 Express Edition than, say, running SQL query scripts.

There have been requests for an update to my SQL Server 2005 article for SQL Server 2008; so, by popular demand, here is the update! This article is based on an installation of Microsoft SQL Server 2008 Express Edition with Tools, Service Pack 1, on a machine with Microsoft Windows Vista Business, Service Pack 1, installed.

I was not 100% sure at first whether to write this new article -- because the user-interface in SQL Server Express 2008 Management Studio is virtually identical to that of the 2005 edition -- but decided to anyway, just so to distinguish between the two versions and to assist users who come up with errors or issues which may possibly be unique to the 2008 version; these errors can be posted and discussed here, separate from the 2005 version's article.

Audience 

SQL Server beginners and database development beginners are the audience for whom this article is written.

I wrote this back in 2007, when I myself was just starting out with SQL Server.  I was searching the documentation and came upon samples making use of the Northwind and the Pubs databases.  However,  I was unable to find anything in MSDN that actually walked one through installing them in SQL Server Management Studio.  Therefore, back then I wrote this article, so as to help other SQL Server beginners.

This is NOT a copy & paste article.  I am an experienced technical writer, and an astrophysicist.  Perhaps it may be the case that Microsoft has already posted new documentation on installing databases into SQL Server Management Studio graphically; however, at the time this article was originally posted back in 2005, at the time I had been unable to locate an equivalent article in the Microsoft documentation; hence, I wrote my own, which has evolved into this article.

So, enjoy this article, for what it's worth.

Background 

It's lost on me why one must use *.sql query scripts to install these samples. It's also lost on me why SQL Server distributions don't come with these databases provided, since they are used so ubiquitously through documentation, websites, and tutorials. There are probably several good reasons for this. However, I am focused on usability, and not on making things harder than they have to be.

There undoubtedly will be readers who will protest and say that I should use *.sql query files whenever possible; this is good and a perfectly acceptable practice. For example, if you have complex queries or you need to attach several databases in a batch, then *.sql query files can be very useful. I see this article as illustrating just another way to accomplish a similar objective.

It's worth noting, for example, that a default Visual Studio .NET 2008 Professional Edition installation does not distribute these databases. Unlike the previous version of Visual Studio .NET, it does not even go part-way by installing the required SQL Scripts --- at least, I have not been able to locate them with the latest version. The download attached to this article contains the latest version of the Northwind and Pubs database files as distributed by Microsoft on MSDN.

Personally, I favor using graphical (GUI) tools and methods over typing cryptic commands and deciphering error messages. So, this article illustrates how to install the Northwind and Pubs databases using graphical tools and methods. 

Steps: Installing the Northwind and Pubs Databases

Note: The steps above make use of SQL Server Management Studio Express, which sometimes doesn't install along with a Microsoft SQL Server 2008 Express Edition install. For this case, you need to install SQL Server 2008 Express with Tools from this website.

Step 1: Using the download link above, download the Zip file containing the following files. Extract the files to a directory on your computer and remember where you put them. For these steps to work, you must have the following files on your computer:

  • NORTHWND.MDF
  • NORTHWND.LDF
  • PUBS.LDF
  • PUBS.MDF

Note: Make sure that you have read-write access to these files, and that they are in an easily-accessible directory. For ease-of-use, I suggest using C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data, or its analogy on your system, which is where Microsoft SQL Server 2008 prefers to store flat database files.

Step 2: On the Start menu, click All Programs, open the Microsoft SQL Server 2008 folder, and then click SQL Server Management Studio.

SQL Server Management Studio starts and displays the Connect to Server window, shown in Figure 1.

Screenshot - InstallNorthwindAndPubs_fig1.jpg

Figure 1. The Connect to Server window

Fill in the appropriate settings on the Connect to Server window that appears, and then click Connect.

SQL Server Management Studio Express opens the Object Explorer with the server's databases displayed.

Step 3: Right-click the Databases folder and then click Attach, as shown in Figure 2.

Screenshot - InstallNorthwindAndPubs_fig2.jpg

Figure 2. The Object Explorer window

Step 4: In the Attach Databases window, click Add....

The system prompts you for the proper *.mdf file using the Locate Database File window, as shown below in Figure 3.

Screenshot - InstallNorthwindAndPubs_fig3.jpg

Figure 3. The Locate Database File window

Step 5: Locate and click on the NORTHWND.MDF file, and then click OK.

The right pane of the Attach Databases window will look as shown in Figure 4.

Screenshot - InstallNorthwindAndPubs_fig4.jpg

Figure 4. The right pane of the Attach Databases window after adding the Northwind database

Step 6: Repeat steps 4 and 5 for the PUBS.MDF file.

When you're done, and if you did the proper actions, the right pane of the Attach Databases window should look as displayed in Figure 5.

Screenshot - InstallNorthwindAndPubs_fig5.jpg

Figure 5. The right pane of the Attach Databases window after adding the Pubs database

Step 7: In the Attach Databases window, click OK. The window displays the progress of the operation and whether it has completed successfully.

Step 8: To check that everything was successful, in the Object Explorer window, click the plus sign to open the Databases folder.

The Northwind and Pubs databases will be displayed, as shown in Figure 6.

Screenshot - InstallNorthwindAndPubs_fig6.jpg

Figure 6. The Object Explorer after importing the Northwind and Pubs databases

Where to Go for Help

Feel free to email me with specific questions about this article, and I will be happy to explain. I also want to invite you to make use of the forums at the bottom of this article. I wish you well and happy programming.

History

In this section, I will keep a running history of the changes and updates I've made to this article:

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader
United States United States
Brian C. Hart, Ph.D., is a strategic engagement leader on a mission to leverage space technology to protect U.S. interests and assets against adversaries. Throughout Dr. Hart's career, he has enjoyed: Working closely with business executives to provide strategic direction and leadership, translating customer and competitive intelligence into compelling capture strategies and solutions, and mentoring teams to enhance individual and company capabilities while fostering an engaging and accountable environment, being involved in STEAM initiatives and education to develop greater awareness in the community, and serving the armed forces with the U.S. Navy and U.S. Army National Guard. He is excited to begin developing his career in Jacobs's Critical Mission Systems business unit, supporting NORAD and the U.S. Space Force.

Comments and Discussions

 
QuestionIncorrect version Pin
Sam Hobbs26-Apr-18 12:42
Sam Hobbs26-Apr-18 12:42 
GeneralThanks Pin
Aung Paing19-Feb-16 17:43
Aung Paing19-Feb-16 17:43 
Questionvery good Pin
Member 1222802824-Dec-15 23:11
Member 1222802824-Dec-15 23:11 
GeneralThanks Pin
David000722-Jul-15 11:16
David000722-Jul-15 11:16 
QuestionAwesome Pin
Member 1180423530-Jun-15 18:52
Member 1180423530-Jun-15 18:52 
GeneralThanks.. Simple and more simple Pin
katheeja.parveen3-Jan-15 11:53
katheeja.parveen3-Jan-15 11:53 
GeneralGood Job Pin
sobo1233-Mar-14 6:38
sobo1233-Mar-14 6:38 
QuestionMicrosoft has a new example database - Adventure Works Pin
Steve Main26-Jul-13 14:47
Steve Main26-Jul-13 14:47 
AnswerRe: Microsoft has a new example database - Adventure Works Pin
Brian C Hart18-Oct-13 8:01
professionalBrian C Hart18-Oct-13 8:01 
GeneralGood Pin
hk7792116-May-13 1:01
hk7792116-May-13 1:01 
GeneralRe: Good Pin
Brian C Hart18-Oct-13 8:01
professionalBrian C Hart18-Oct-13 8:01 
GeneralMy vote of 5 Pin
Member 1004981613-May-13 15:51
Member 1004981613-May-13 15:51 
GeneralRe: My vote of 5 Pin
Brian C Hart18-Oct-13 8:01
professionalBrian C Hart18-Oct-13 8:01 
QuestionThank you! Pin
VitaliiS4-Mar-13 7:45
VitaliiS4-Mar-13 7:45 
AnswerRe: Thank you! Pin
Brian C Hart18-Oct-13 8:01
professionalBrian C Hart18-Oct-13 8:01 
QuestionGood guide but a note on failure for the benefits of other users Pin
AlekMirkin18-Feb-13 6:05
AlekMirkin18-Feb-13 6:05 
AnswerRe: Good guide but a note on failure for the benefits of other users Pin
Brian C Hart18-Oct-13 8:02
professionalBrian C Hart18-Oct-13 8:02 
QuestionNorthWind Pin
Tad2127-Dec-12 13:02
Tad2127-Dec-12 13:02 
GeneralMy vote of 4 Pin
Member 95218577-Nov-12 20:39
Member 95218577-Nov-12 20:39 
GeneralBloody brilliant! Pin
Woogie210-Sep-12 16:05
Woogie210-Sep-12 16:05 
GeneralRe: Bloody brilliant! Pin
Brian C Hart11-Sep-12 7:44
professionalBrian C Hart11-Sep-12 7:44 
GeneralMy vote of 5 Pin
ashokjavvaji28-Aug-12 7:23
ashokjavvaji28-Aug-12 7:23 
GeneralRe: My vote of 5 Pin
Brian C Hart11-Sep-12 7:44
professionalBrian C Hart11-Sep-12 7:44 
GeneralMy vote of 5 Pin
Ashanb17-Aug-12 4:20
Ashanb17-Aug-12 4:20 
GeneralRe: My vote of 5 Pin
Brian C Hart11-Sep-12 7:44
professionalBrian C Hart11-Sep-12 7:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.