Inserting multiple rows in a single SQL query

0 votes

I have a set of  multiple values to insert in a table at once, like 4 rows. My table has three columns: Name, EmployeeId and Salary.

INSERT INTO Table VALUES ("Aman", 112, "30000");
INSERT INTO Table VALUES ("Ajay", 113, "30000");
INSERT INTO Table VALUES ("Akshay", 114, "40000");
INSERT INTO Table VALUES ("Abhishek", 115, "50000");

How to insert all the four rows in one single SQL statement?

Feb 10, 2022 in Database by Neha
• 9,060 points
809 views

1 answer to this question.

0 votes

In SQL Server 2008, multiple rows can be inserted using only a single SQL INSERT statement.

INSERT INTO MyTable ( Column1, Column2 ) VALUES
( Value1, Value2 ), ( Value1, Value2 )

For example:

INSERT INTO MyTable
  ( Column1, Column2, Column3 )
VALUES
  ('Aman', 112, '30000'), 
  ('Ajay', 113, '30000'), 
  ('Akshay', 114, '40000'),
  ('Abhishek', 115, '50000');
answered Feb 10, 2022 by Vaani
• 7,020 points

Related Questions In Database

0 votes
0 answers

How to DROP multiple columns with a single ALTER TABLE statement in SQL Server?

In one ALTER TABLE statement, I would ...READ MORE

Sep 2, 2022 in Database by Kithuzzz
• 38,010 points
505 views
0 votes
1 answer

Can I have multiple primary keys in a single table?

A Table can have a Composite Primary Key which ...READ MORE

answered Oct 25, 2018 in Database by Frankie
• 9,830 points
3,340 views
0 votes
1 answer

SQL count rows in a table

A fast way of doing this would ...READ MORE

answered Feb 21, 2022 in Database by Neha
• 9,060 points
560 views
0 votes
0 answers

How to find sum of multiple columns in a table in SQL Server 2005?

I have a table Emp which has these rows: Emp_cd ...READ MORE

Aug 19, 2022 in Database by Kithuzzz
• 38,010 points
1,360 views
0 votes
0 answers

How do I UPDATE from a SELECT in SQL Server?

INSERT INTO Table (col1, col2, col3) SELECT col1, ...READ MORE

Feb 4, 2022 in Database by Vaani
• 7,020 points
329 views
0 votes
1 answer

What is a stored procedure?

A stored procedure is a set of ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
805 views
0 votes
1 answer

LEFT JOIN vs. LEFT OUTER JOIN in SQL Server

At the top level there are mainly ...READ MORE

answered Feb 4, 2022 in Database by Neha
• 9,060 points
1,660 views
0 votes
1 answer

SQL Server: PARTITION BY vs GROUP BY

To understand the differences between GROUP BY ...READ MORE

answered Feb 9, 2022 in Database by Neha
• 9,060 points
2,217 views
0 votes
1 answer

How do I UPDATE from a SELECT in SQL Server?

MERGE INTO YourTable T USING ...READ MORE

answered Feb 3, 2022 in Database by Vaani
• 7,020 points
600 views
0 votes
1 answer

Convert Rows to columns using 'Pivot' in SQL Server

You can use the PIVOT function to ...READ MORE

answered Feb 8, 2022 in Database by Vaani
• 7,020 points
1,316 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP