Microsoft SQL Server Topics: Creating a Table


Visually Creating a Table

To visually create a table, in the Object Explorer, expand the Databases node and expand the database to which the table will belong. Right-click the Tables node and click New Table...

Visually Creating a Table

This would create a Table window.


Creating a Table With SQL

The Data Definition Language (DDL) command to create a table is CRE TE TABLE. Here are examples:

Example 1:

CREATE TABLE LibraryMembers
    Gender char


Temporary Tables

After creating a table, it becomes part of its database and you can use that table over and over again. In some cases, you may want to create a table to test something and you would not need to use that table the next time you connect to the server. Such a table is referred to as a temporary table.

To create a temporary table, use the poind sign, #, after CREATE TABLE. Once the table has been created, it would be available as long as you are using the same connection to the server. If you close Microsoft SQL Server, the table would be automatically deleted.

Home Copyright © 2003-2013, FunctionX