SQL SERVER

Create Table in SQL Server

In SQL Server by Baqir AliLeave a Comment

Create Table

Create Table command is used to create a table in SQL Server. Create Table Command syntax is as follows.

<create keyword> Table <table name>
{
    <attribute name>  <data type>(length)
}

In order to create a table in T-SQL, we use the keyword ‘Create Table’

Example 1 Create Table Command:

CREATE TABLE Student(
    StudentID INT, 
    Name VARCHAR(50),
    CourseID INT
)
TypeDescription
StudentName of the Table
INTDefines StudentID that only stores integer data type
VarcharStores character with a length of 10 characters

Example 2 Create Table Command :

CREATE TABLE Employee_Department
(
  Employee_No INT NOT NULL,
  Employee_Name VARCHAR(50),
  Employee_Type VARCHAR(50),
  Department_No INT NOT NULL,
  Department_Name VARCHAR(50)
 )
TypeDescription
Employee_DepartmentName of the Table
NOT NULLAttribute type that it can not be NULL
Varchar(50)Stores character with a length of 50 characters

Example 3 Create Table Command :

CREATE TABLE Courses(
    CourseID INT, 
    Name VARCHAR(20)
)

Example 4 Create Table Command :

CREATE TABLE Employee(
    Employee_No INT NOT NULL,
    Department_No INT NOT NULL,
    Employee_Name VARCHAR(50),
    Employee_Type VARCHAR(50),
    Manager_ID INT
)

Example 5 Create Table Command :

CREATE TABLE Department
(
    Department_No INT NOT NULL,
    Department_Name VARCHAR(50)
)
Create Table in SQL Server

Support us by sharing this post

About the Author

Baqir Ali

Facebook Twitter

Hi, I am Baqir Ali ---- Blogger, Programmer, and a Teacher. I am currently working as a Programmer for Softnat Technologies. I have tons of ideas and data to share with you all via blogging.

Leave a Comment