Home > 2010 Winter BTI420 > Copying Northwind tables to your database to enable insert/update/delete

Copying Northwind tables to your database to enable insert/update/delete

February 21, 2010 Leave a comment Go to comments

Learn how to copy tables from the Northwind sample database, to your own database. This will enable you to perform all common select, insert, update, and delete operations.

 

All BTI420 students have read-only access to the Northwind sample database. The instructions below enable you to copy the tables to your own database. That way, you can learn about data access without having to create sample data, and perform all common database operations.

 

Download the script

This task is performed only once.

Your professor has created a script that will do the work, after you make one small editing change. The script is in plain text format, and is available here:

http://warp.senecac.on.ca/peter/bti420/resources/CopyNorthwindTables.txt

Download it to your computer. Then, open it in Notepad. You will need its text in the next step.

 

Use SQL Server Management Studio to run the script

This task is performed only once.

Start the SQL Server Management Studio program. This program may already be installed on your own computer. Alternatively, it is installed on College computers – except for those in room T2109.

Connect to your database ("Connect to server" dialog box). Then, scroll to locate your database in the left-side object navigator, and open/expand it, so that you can see the list of your database’s tables.

Right-click your database name in the left-side object navigator. Choose New Query, and a new query window will open.

Copy the script text from the Notepad window (above), and paste it into the Management Studio’s query window.

Near the top, you will see a SQL command that begins with "use…". Replace the "YourOwnDatabaseName" with your own database name. Then, execute the query, by clicking on the toolbar icon (or by choosing Query > Execute).

As you can see from the query’s commands, it will first attempt to drop old versions of Northwind tables. If it doesn’t find old versions, it will show error messages, which you would expect. Then, the query creates the tables, and copies the data from Northwind.

Right-click your "Tables" folder in the left-side object navigator, and choose Refresh. Your new tables will appear on the list.

 

The new table names are prefixed with "nw"

All of the new table names are prefixed with "nw". For example, the Northwind Employees table is now called "nwEmployees".

This naming convention groups the Northwind tables together, and enables you – if you want – to create a table in the future called "Employees".

 


Advertisements
Categories: 2010 Winter BTI420
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: