Tuesday, January 24, 2012

How To Create Table in SQL Server

There are various way we can create table in SQL Server But Here I will Discuss the convenient way to make the Data Table on SQL Server .

Here I will make the Table On SQL Server 2008 with snapshot so which is easy to understand.

As we have seen in last post that how to create Database using Server Explorer .

Today we will see how to create the Table with SQL various functionality .

in the give example we have created New Table Named as "db_test"

Now to create the table right click ont the table you will see "New Table" option click on it.

Here I have created table without any Primary Key but very useful way to create the table.

Let's see the Example 

Here we can see the I have Created simple Table with five field .
let's see the advantage of this type of Data Table

First I have Created Column "id" with data type integer here i have unchecked the allow nulls.
Now look at the column property in that focus on "Identity Specification" in that double click on is identity you will see column property as given below exmaples.

Here it will show the auto increment when add the column here "Identity Increment " specify the increment in number and "Identity Seed" specify that from where to start count for the auto increment .

so by using this simple property you can have new distinct "ID" number each time when you have create new rows . so no conflict can be generated  and  your table will work smoothly 

No comments:

Post a Comment