MS SQL Insert query

The SQL INSERT INTO Statement is used to add new rows of data to a table in the database

 

Syntax: single insert


INSERT INTO [table-name] ([column1], [column2], .., [columnN])
                       VALUES ('[value1]','[value2]',...,[valueN])

Syntax: insert by select


INSERT INTO tblCustomers ([column1], [column2], .., [columnN])
                       SELECT [column1], [column2], .., [columnN]
                       FROM [table-2] 

 

Example: single insert


INSERT INTO tblCustomers (Name, Age, Address, Salary)
                       VALUES ('john',24,'1st Street',$4000)

Example: insert by select


INSERT INTO tblCustomers (Name, Age, Address, Salary)
                       SELECT Name, Age, Address, Salary
                       FROM tblTmpData

Summary:

SQL - INSERT Query, The SQL INSERT INTO Statement is used to add new rows of data to a table in the database.