Monday, May 10, 2010

SQL SERVER - How To Create a Table using Table Designer in Management Studio

In Previous articles, we have seen various database Objects that are available in SQL Server.Now we see each and every database object in detail.

Now we will see the creation of a Table using the SQL Server Management Studio’s Table Designer.

In general, the table is nothing but the collection of rows and columns. Here Rows can be called as Records and the Columns can be called as fields. The columns in a table must satisfy different the constraints like Integrity Constraint, Check Constraint, Default Constraints , Primary Key Constraints, Foreign key Constraints and Not null Constraint etc..

Now we will see how to create a table using table designer.

As a first step,  Open Microsoft SQL Server Management Studio and connect to the server where we want to add a table.

image

Now Expand the Databases folder and select the database where we want to create a new Table.

 image

After that, Expand the Database and select  the sub folder ‘Tables’

image

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

image

image 

Now we add the required columns to the table. 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 we  want to allow NULL values in this column, click "Allow Nulls".
Repeat this process until you've added all the required columns to our SQL Server database table.

image

Now select the the column that you've selected for your table's Primary Key and 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.

image

Once you've done this, the primary key column(s) will have a key symbol.

Now save the table by giving the unique table name.

image

Finally the Table has been created with the specified Unique table Name

image

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.