SQL-Server-Insert .

In this session i have discussed the SQL Server Insert .


The SQL Server Insert is used to add new records in table .


There are two ways by which you can insert the record in table .

Insert Syntax .

The below code specify how to use the Insert .

In first way you can specify the column names and values both in the sql statement .

  INSERT INTO Table_Name(Column1,Column2,Column3) values(value1,value2,value3)
    

In the second way you do not need to specify the column name if you want to add all column values but take care of the order .

    INSERT INTO Table_Name values(value1,value2,value3)
    

Database Demo

The following data shown by Employee table of abc database .

EmpID EmpName EmpCity EmpEmail
1 Amit Noida amit@gmail.com
2 Amita Noida amita@gmail.com
3 Amita Delhi amita123@gmail.com

Insert Example .

Insert the data in specified column of table Employee .

    INSERT INTO Employee(EmpID,EmpName) values(4,'Ramesh')
    

The output is look like below .

EmpID EmpName EmpCity EmpEmail
1 Amit Noida amit@gmail.com
2 Amita Noida amita@gmail.com
3 Amita Delhi amita123@gmail.com
4 Ramesh null null

.


Insert the data in all column of table Employee .

    INSERT INTO Employee values(5,'Rakesh','Gorakhpur','rakesh@gmail.com')
    

The output is look like below .

EmpID EmpName EmpCity EmpEmail
1 Amit Noida amit@gmail.com
2 Amita Noida amita@gmail.com
3 Amita Delhi amita123@gmail.com
4 Ramesh null null
5 Rakesh Gorakhpur rakesh@gmail.com

.


Welcome to AndroidATPoint.

back image                     next image