Create table in ms sqlserver

When we use create table statement in sqlserver, we should keep in mind some elementary things like :

  1. Table's name.
  2. Number of columns and names of columns.
  3. Data type of each column and allocated length.
  4. Default value for column(s).
  5. Primary key column(s) etc.
 
The basic syntax to create a table is as follows:

CREATE TABLE table_name
(
column_name1 data type [NOT NULL],
column_name2 data type [NOT NULL],
column_name3 data type [NOT NULL],
) ;

Now taking an example for create table with name student :

CREATE TABLE student
(  ID   INT NOT NULL,
   StudentName  VARCHAR(50) NOT NULL,
   DOB  DATETIME NOT NULL,
   Phone  VARCHAR(12) NULL,
   Email  VARCHAR(75) NOT NULL,
   Street  VARCHAR(50) NOT NULL,
   City  VARCHAR(50) NOT NULL,
   Zip  NUMERIC(6, 0) NOT NULL,
);
 
Eight different columns make up this table. Each column has been assigned data type and length except ID column and DOB. Because INT data type and DATETIME data type already have  fix length.By using the NOT NULL constraint, we specified columns require values and where we used  NULL, means there may be record(s) without value for that column.