The SQL Server INSERT INTO explanation is utilized to add new lines of information to a table in the data set.
Syntax
Following are the two essential language structures of INSERT INTO articulation.
INSERT INTO TABLE_NAME [(column1, column2, column3,...columnN)]
VALUES (value1, value2, value3,...valueN);
Where column1, column2,...columnN are the names of the segments in the table into which you need to embed information.
You need not determine the column(s) name in the SQL question in the event that you are adding values for all the sections of the table. In any case, ensure the request for the qualities is in similar request as the segments in the table. Following is the SQL INSERT INTO linguistic structure −
INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);
Example
Following explanations will make six records in CUSTOMERS table −
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (1, 'Ramesh', 32, 'Ahmedabad', 2000.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (2, 'Khilan', 25, 'Delhi', 1500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (3, 'kaushik', 23, 'Kota', 2000.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (4, 'Chaitali', 25, 'Mumbai', 6500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (5, 'Hardik', 27, 'Bhopal', 8500.00 );
INSERT INTO CUSTOMERS (ID,NAME,AGE,ADDRESS,SALARY)
VALUES (6, 'Komal', 22, 'MP', 4500.00 );
Syntax
You can make a record in CUSTOMERS table utilizing second punctuation as follows −
INSERT INTO CUSTOMERS VALUES (7, 'Muffy', 24, 'Indore', 10000.00 );
All the above assertions will deliver the accompanying records in CUSTOMERS table −
ID NAME AGE ADDRESS SALARY
1 Ramesh 32 Ahmedabad 2000.00
2 Khilan 25 Delhi 1500.00
3 kaushik 23 Kota 2000.00
4 Chaitali 25 Mumbai 6500.00
5 Hardik 27 Bhopal 8500.00
6 Komal 22 MP 4500.00
7 Muffy 24 Indore 10000.00
Populate One Table Using Another Table
You can populate information into a table through SELECT assertion over another table gave another table has a bunch of fields, which are needed to populate first table. Following is the language structure −
INSERT INTO first_table_name
SELECT column1, column2, ...columnN
FROM second_table_name
[WHERE condition];