What is and how do I install the Northwind database?

The Northwind database is referenced online in sample code quite often. However, this renders the sample code useless to someone who doesn’t know what Northwind is or how to use it.

The Northwind database is basically just an example database that runs under SQL Server. This database is populated with data that represents an imaginary company’s sales data. It is a very common example database for SQL Server testing and sampling.

You might be wondering, what is SQL Server (though for your sake, I hope not). Well, SQL Server is Microsoft’s database software.

How do I know if SQL is installed?
If you have Visual Studio 2008 installed, you probably have SQL Server 2008 installed and you don’t even know it.

You can go to Add / Remove Programs and look for Microsoft SQL Server.

Or you can check for the services.

Or if you aren’t good with the GUI, you can open a command prompt and run this command to see if you have the SQL services:

C:\Users\UserName> sc query state= all |findstr SQL |findstr DISPLAY_NAME

DISPLAY_NAME: SQL Active Directory Helper Service
DISPLAY_NAME: SQL Server Browser

If you don’t see the services ouptut, you don’t have SQL Server Express installed. If you do have it, it is installed.

SQL Server is installed, now where do I get the Northwind Database?
Well, this was a struggle even for me. All the posts say the database creation script was installed with Visual Studio, but I sure don’t have any database creation scripts installed.

So I searched the web and Microsoft’s site for a while.

I finally found this link, but not until after about an hour of searching, hopefully this saves you some time.

So as of 3/4/2010, there was not “new” Northwind database, just and old one for SQL 2000. Which is fine because that old database is what most the sample code you find will be using.

I clicked on the Download link next to SQL Server 2000 Sample DBs.
I downloaded a ZIP file.
I extracted it.
I found the instnwnd.sql script among the extracted files.

How do I use the instnwnd.sql file to install the Northwind Database
This instnwnd.sql is nothing more than SQL script that will install the Northwind database for you. Well, you basically need your SQL server to run this script file and that is it.

If you have SQL Server Management Studio, just open it up and connect to your database, then File | Open the script and run it. But maybe you don’t know what SQL Server Management Studio is, let alone how to open it.

Sound easy right.

Well, everything sounds easy to some one who knows exactly how to do it, but if you don’t now how, it doesn’t sound easy. If you are among those that are hearing about this for the first time, let me help you.

Well, every server that has SQL Server installed has a command line tool installed called sqlcmd.exe. Hey, if I give you a command line you can run it, even if you don’t know what is really going on.

So just open a command prompt and run this command:

C:\Users\UserName> sqlcmd -E -i c:\path\to\instnwnd.sql

Changed database context to ‘master’.
Changed database context to ‘Northwind’.

Ok, the database installed now what?
Well, now you have the Northwind database installed.

From here you are one your own getting whatever sample code you have to connect to this database and compile.


  1. tho says:

    I have installed Northwind but when i try to connect by using the code below it has comment like that:
    when i use windown xp i don't see any problem, however i change to use win 7, i can not access to the northwind. can you help me to solve this problem.

    C:\Users\UserName>sqlcmd -E -i c:\path\to\instnwnd.sql
    Sqlcmd: Error: Error occurred while opening or operating on file c:\path\to\intnwnd.sql

  2. Jessie says:

    Nice article saved me a ton of time - thank you!

  3. dino says:

    I downloaded files and put then into a northwind directory like below, but I got following error:

    C:\Users\ME>cd northwind

    Volume in drive C has no label.
    Volume Serial Number is E412-D2BE

    Directory of C:\Users\ME\Northwind

    15/07/2012 09:06 PM .
    15/07/2012 09:06 PM ..
    04/02/2004 08:45 AM 2,115,268 instnwnd.sql
    23/03/2004 10:50 AM 128,520 instpubs.sql
    13/12/2004 04:14 PM 1,048,576 NORTHWND.LDF
    13/12/2004 04:14 PM 2,752,512 NORTHWND.MDF
    13/12/2004 04:14 PM 1,310,720 PUBS.MDF
    13/12/2004 04:14 PM 786,432 PUBS_LOG.LDF
    23/03/2004 10:50 AM 61,500 ReadMe_SQL2000SampleDbScripts.htm
    7 File(s) 8,203,528 bytes
    2 Dir(s) 17,207,984,128 bytes free

    C:\Users\ME\Northwind>sqlcmd -E -i instnwnd.sql
    HResult 0x2, Level 16, State 1
    Named Pipes Provider: Could not open a connection to SQL Server [2].
    Sqlcmd: Error: Microsoft SQL Native Client : An error has occurred while establi
    shing a connection to the server. When connecting to SQL Server 2005, this failu
    re may be caused by the fact that under the default settings SQL Server does not
    allow remote connections..
    Sqlcmd: Error: Microsoft SQL Native Client : Login timeout expired.


Leave a Reply

How to post code in comments?