Quackit Logo

Got a MySpace Page?

Get "www.yourname.com" for your MySpace page. Learn how >>.

SQL Server - Create a Table

Print Version

This lesson demonstrates how to create a table in a SQL Server database using Enterprise Manager.

  1. Ensuring you have the right database expanded, right click on the "Tables" icon and select "New Table...":
    Creating a table in SQL Server - step 1
  2. While you have this screen open, do the following:
    1. Using the values in the screenshot, complete the details in the "Column Name" column, the "Data Type" column, "Length" column, and "Allow Nulls" column.
    2. Make the IndividualId column an "identity column", by setting "Identity" to "Yes" (just use the same values as in the screenshot). Note that to set values in the bottom pane, you need to select the column name in the top pane first). This column is going to be an auto-number column - it will contain an incrementing number for each record that is created.
    3. Set the "Default Value" of the DateCreated column to (getdate()). (This will automatically insert the current date into that field for each new record).
    Creating a table in SQL Server - step 2

    What we are doing at this stage, is creating the column names, specifying the type of data that can be entered into them, and setting default values. Restricting the data type for each column is very important and helps maintain data integrity. For example, it can prevent us from accidentally entering an email address into a field for storing the current date.

  3. Close the table by clicking the close icon Close table icon, and when prompted, name your table:
    Creating a table in SQL Server - step 3

Your New Table

Now that you've created a new table, it will appear under your database in the "Tables" section.

Viewing the contents of your table

 

Enjoy this website?

  1. Link to this page (copy/paste into your own website or blog):
  2. Add this page to your favorite social bookmarks sites:
                     
  3. Add this page to your Favorites

Oh, and thank you for supporting Quackit!

FREE Hosting!

With every domain name you register with ZappyHost, you get FREE (ad supported) hosting.

PLUS you get:

  • FREE Website Builder
  • FREE Blog
  • FREE Starter Web Page
  • FREE Email Account
  • & much more! (Total value $123 for FREE!)
Get your FREE hosting today! >>