Google

Monday, October 8, 2007

How to Attach an Existing Database to MS SQL Server 2005

I will use the Northwind Database Sample to demonstrate. You will need the following:

1. Microsoft SQL Server 2005 Express
2. Microsoft SQL Server Management Studio Express
3. SQLSampleDb.msi file which contains the Pubs and Northwind mdf Database

All of the above can be downloaded for free from Microsoft from the following links:

Item 1 : http://www.microsoft.com/sql/editions/express/howtobuy.mspx

Item 2: http://www.microsoft.com/downloads/details.aspx?FamilyID=c243a5ae-4bd1-4e3d-94b8-5a0f62bf7796&DisplayLang=en

Item 3: http://www.microsoft.com/downloads/details.aspx?familyid=06616212-0356-46a0-8da2-eebc53a68034&displaylang=en

After installing everything, Item 3 (the Pubs and Northwind databases) will be located in C:\SQL Server 2000 Sample Databases

Fire up your MS SQL Server 2005 Management Studio. Login to SQL Server (no need password). Then to attach the Northwind database, do the following.

1. In the Object Explorer Tree View, expand the Databases Node.









2. Right-click the Databases Node. In the Context Menu that appears, select Attach...

3. In the Attach Databases Dialog that appears, Click on Add...

4. In the Locate Databases Dialog that appears, navigate to the folder C:\SQL Server 2000 Sample Databases. Select the NORTHWND.MDF file then click OK.



5. You wil now be able to see two new files in the Attach Databases Dialog, i.e. northwnd.mdf and northwnd.ldf.



5. Click OK. You will now be able to see the new Northwind Database Node as shown by the red arrow below.


6. Congratulations. You have successfully attached the Northwind Databases to MS SQL Server 2005 Express.