Click here to Skip to main content
Click here to Skip to main content

HowTo: Install the Northwind and Pubs Sample Databases

, 18 Oct 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
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.
Note: SQL Server 2008 Users Click Here for the SQL Server 2008 version of this article



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 2005 Express Edition than, say, running SQL query scripts.

This article is to help you get started quickly with SQL Server samples, so as to use them to learn basic techniques.


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

I wrote this back in 2005, 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.


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. 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 2005 Standard Edition installation does not distribute these databases. It goes part-way, creating a Program Files\Microsoft Visual Studio 8\SDK\Samples\Setup directory containing, e.g., instnwnd.sql, a query script that ostensibly can be used to install the Northwind sample database.

However, hats off to Microsoft for putting apples with apples. Microsoft provides the queries for installing, but not the *.mdf and *.ldf files for the databases themselves. This does not support users in installing these important samples into SQL Server. Perhaps there's an easier way: this article. The download attached to this article contains the SQL Server 2000 versions of these files.

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

Steps: Installing the Northwind and Pubs Databases

Note: The steps here make use of SQL Server Management Studio Express, which sometimes doesn't install along with a Microsoft SQL Server 2005 Express Edition install. For this case, SQL Server Management Studio Express is available as a separate download from Microsoft.

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:


Step 2: On the Start menu, point to Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio Express.

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.

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. Click here for the SQL Server 2008 version of this explanation.


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


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


About the Author

Brian C Hart
Software Developer (Senior) Corrugated Technologies, Inc.
United States United States
From Fridley, Minnesota and I like computer programming! When I got started, I was working mostly with Windows GUI programming in C/C++. Then later on I worked with COM/DCOM for a school internship. I used COM/DCOM to write an ad hoc cluster server and job-running environment for a cluster of 24 Windows-based high-end visualization workstations. I moved on to C# and have been working in C# and Windows Forms ever since. I have yet to embrace Silverlight Smile | :)
Follow on   Twitter

Comments and Discussions

Questionerror when attaching the db PinmemberMember 113498023-Jan-15 7:08 
QuestionDoes this work with newer versions of MS SQL? PinmemberTomaszWyb18-Oct-13 7:33 
AnswerRe: Does this work with newer versions of MS SQL? PinmemberBrian C Hart18-Oct-13 8:54 
GeneralRe: Does this work with newer versions of MS SQL? PinmemberTomaszWyb18-Oct-13 9:49 
GeneralWell Done..!! PinmemberTedPalmer16-Oct-13 19:23 
GeneralMessage Automatically Removed PinmemberMahBulgaria29-Aug-13 0:44 
GeneralRe: My vote of 2 PinmemberBrian C Hart17-Oct-13 7:19 
GeneralRe: My vote of 2 PinmemberMahBulgaria22-Oct-13 12:27 
GeneralGood Article PinmemberAlireza_13627-May-13 18:58 
Questionit is really nice PinmemberMember 990282911-Mar-13 19:54 
GeneralMy vote of 5 PinmemberSavalia Manoj M27-Feb-13 17:55 
GeneralMy vote of 5 PinmemberWhiteOsoBDN26-Feb-13 3:46 
GeneralMy vote of 5 Pinmemberpron116-Jan-13 16:38 
QuestionSQL Server 2005 Install/Upgrade PinmemberGoldstar Lee13-Jan-13 7:49 
GeneralMy vote of 5 PinmemberAmol_B2-Jan-13 0:18 
Questionspot on explanation PinmemberJim Millecam19-Dec-12 10:53 
Questionhihi thanks Pinmemberhaiyentink1025-Oct-12 16:26 
GeneralEasy as it gets PinmemberMember 950286110-Oct-12 15:50 
QuestionThanks so much PinmemberRonnieVN3-Aug-12 23:11 
QuestionConnect to Server? Pinmembermetonym19-Jul-12 6:30 
AnswerRe: Connect to Server? PinmemberBrian C Hart19-Jul-12 7:05 
GeneralRe: Connect to Server? Pinmembermetonym23-Jul-12 0:23 
QuestionThanks Brian Pinmembersandeep1968-Jun-12 0:20 
QuestionTHANKS VERY MUCH Pinmemberpofante7-Jun-12 1:09 
QuestionThanks PinmemberMrNilesh4-Jun-12 21:54 
QuestionThanks PinmemberMember 858559930-Apr-12 11:31 
QuestionThanks PinmemberMuhammad Tausif29-Apr-12 17:20 
GeneralThanks Brian PinmemberMember 857561217-Jan-12 15:03 
GeneralThanks!!! [modified] PinmemberCNote883-Jan-12 4:01 
Questionmy vote for 5 Pinmembercostavo17-Dec-11 12:35 
GeneralMy vote of 5 PinmemberPomel16-Jun-11 8:10 
GeneralMy vote of 5 Pinmembertebogoph19-Apr-11 1:21 
GeneralMy vote of 5 PinmemberAnup Daware10-Apr-11 21:27 
GeneralMy vote of 5 Pinmemberhbtb8-Apr-11 4:48 
GeneralInstalling Northwind data base PinmemberMember 209771228-Sep-10 23:25 
Generaldownload PinmemberSmon the Vidd10-Aug-10 3:10 
GeneralMy vote of 5 Pinmembersandeepraju2-Aug-10 22:33 
GeneralMy vote of 5 PinmemberMikJr27-Jul-10 15:38 
GeneralIf you are running SQL Server 2008 under Windows 7 PinmemberDHCut25-Feb-10 1:41 
GeneralMy vote of 1 Pinmembercortega8-Oct-09 5:36 
GeneralRe: My vote of 5 PinmemberARon_8-Oct-09 8:41 
GeneralThanks PinmemberKumarIyer29-Sep-09 12:05 
GeneralNorthwind Connection Problems PinmemberNathanlc12-Mar-09 20:08 
NewsNorthwind and Pubs for SQL 2000 and up from Microsoft PinmemberMember 109431628-Jan-09 21:53 
QuestionAn error provided when attaching the DB files Pinmembermohanednoon14-Oct-08 2:40 
AnswerRe: An error provided when attaching the DB files Pinmembermohanednoon16-Oct-08 1:26 
GeneralRe: An error provided when attaching the DB files PinmemberJyotiDudeja20-Feb-09 7:09 
GeneralRe: An error provided when attaching the DB files PinmemberculminIT22-Apr-09 23:51 
GeneralHOWTO: Install the Northwind and Pubs Sample Databases Pinmemberrobhelle17-Sep-08 7:43 
GeneralSQL Server 2008 PinmemberJerry Evans28-Aug-08 8:25 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150331.1 | Last Updated 18 Oct 2013
Article Copyright 2007 by Brian C Hart
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid