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
997 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,070 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,020 points
668 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,690 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
712 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,020 points
1,536 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,070 points
474 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
998 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,942 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,547 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,070 points
773 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,070 points
1,552 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