Install Sample Databases
The databases, such Northwind and Pubs, are sample databases which are used for testing and developing on SQL Server. They are widely used in many sample source code and referenced by many tutorials. So if you are a developer or want to learn about SQL on SQL Server, these databases are needed to be installed on your development PC.
This article shows how to install Northwind and Pubs databases on Microsoft SQL Server 2008 Express.
Step-by-step to install sample databases
- Browse to SQL Server 2000 Sample Databases and click on SQL2000.Sample.Databases.(Northwind,pubs).zip to download the Northwind and Pubs databases. Once you clicked the file, there will be a pop-up displays license of this file. Click I Agree to download the file.
Note: This file contains sample databases that can be used on SQL Server 2000/2005/2008.
- Extract the zipped file, you will see files as the figure below. There are two methods to install these sample databases on SQL Server. The first method, run query on the SQL Server using instnwnd.sql and instpubs.sql for Northwind and Pubs databases respectively. The second method, attach database on SQL Server using NORTHWND.LDF and NORTHWND.MDF for Northwind database and PUBS.MDF and PUBS_LOG.MDF for Pubs database. On this article, I will show how to install Northwind and Pubs databases using the second method.
- Open Microsoft SQL Server Management Studio and connect to your SQL Server.
- Once the connection has been established, right-click on Databases and select Attach.
- On Attach Databases, click Add in Databases to attach section.
- On Locate Database File, browse to the folder where you extracted the downloaded file in step 2. Select a database file that you want to attach. I select NORTHWND.MDF which refers to Northwind database and click OK.
- You will see detail of Northwind database. The NORTHWND.LDF is automatically added in the details on section below (“Northwind” database details).
- Repeat step 5 and 6 for Pubs database by attach PUBS.MDF file if you want to attach more than one database at the time. After you finish selecting databases that you want to attach, click OK.
- If there is no error, you will see the sample databases (Northwind and Pubs) list on the SQL Server as the figure below. Now you can use these sample databases as you want.