Creating Tables in Microsoft SQL Server 2008

Woman sitting in office at desk.
Kelvin Murray/Getty Images

SQL Server databases rely upon tables to store data. In this tutorial, we'll explore the process of designing and implementing a database table in Microsoft SQL Server.

The first step of implementing a SQL Server table is decidedly non-technical. Sit down with a pencil and paper and sketch out the design of your database. You'll want to ensure that you include appropriate fields for your business needs and select the correct data types to hold your data.

Make sure to become familiar with database normalization basics before delving into creating tables in Microsoft SQL Server.

of 06

Start SQL Server Management Studio

SQL Server Management Studio screenshot

Open Microsoft SQL Server Management Studio (SSMS) and connect to the server where you'd like to add a new table.

of 06

Expand the Tables Folder for the Appropriate Database

SSMS Tables Folder screenshot

Once you've connected to the right SQL Server, expand the Databases folder and select the database where you'd like to add a new table. Expand that database's folder and then expand the Tables subfolder.

of 06

Start Table Designer

SQL Server Table Designer screenshot

Right-click on the Tables subfolder and select the New Table option. This will start SQL Server's graphical Table Designer, as shown in the image above.

of 06

Add Columns to Your Table

Creating Table Columns screenshot

Now it's time to add the columns you designed in step 1. Begin by clicking in the first empty cell under the Column Name heading in Table Designer.

Once you've entered an appropriate name, select the data type from the drop-down box in the next column. If you're using a data type that allows different lengths, you may specify the exact length by changing the value that appears in parentheses following the data type name.

If you'd like to allow NULL values in this column, click Allow Nulls.

Repeat this process until you've added all the necessary columns to your SQL Server database table.

of 06

Select a Primary Key

Setting the Primary Key screenshot

Next, highlight the column(s) that you've selected for your table's primary key. Then click the key icon in the taskbar to set the primary key. If you have a multivalued primary key, use the CTRL key to highlight multiple rows before clicking the key icon.

Once you've done this, the primary key column(s) will have a key symbol, as shown in the image above.

of 06

Save Your New Table

Don't forget to save your table! When you click the save icon for the first time, you'll be asked to provide a unique name for your table.