Introduction:

In this article we will explain how to create a table in sql server database with example.


Description:

SQL Server CREATE TABLE statement is used to create table in a database.

If you want to create a table in sqlserver database, you should name the table and define its column and each column's data type.

Let's see the simple syntax to create the table.

create table "tablename"  
("column1" "data type",  
"column2" "data type",  
"column3" "data type""columnN" "data type"
); 


Let us take an example to create a Customer table with ID as primary key with auto increment and NOT NULL are the constraint showing that these fields cannot be NULL while creating records in the table.

CREATE TABLE Customer
( 
[ID] INT PRIMARY KEY IDENTITY(1,1), 
[NAME] VARCHAR (20) NOT NULL, 
[AGE] INT NOT NULL, 
[ADDRESS] VARCHAR (250)
);


I hope this article will help to you..


comments


Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like