Creating Tables in Microsoft SQL Server 2008

01
of 07

Design Your Table

People Images/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.

You may wish to consult our Database Normalization Basics article for some tips on proper database design.

02
of 07

Start SQL Server Management Studio

SQL Server Management Studio. Mike Chapple

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

03
of 07

Expand the Tables Folder for the Appropriate Database

SSMS Tables Folder. Mike Chapple

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.

04
of 07

Start Table Designer

SQL Server Table Designer. Mike Chapple

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.

05
of 07

Add Columns to Your Table

Creating Table Columns. Mike Chapple

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 necessary columns to your SQL Server database table.

06
of 07

Select a Primary Key

Setting the Primary Key. Mike Chapple

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.

If you need assistance, you might want to read the article Selecting a Primary Key.

07
of 07

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.