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 in Database by Neha
• 8,560 points
42 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 by Vaani
• 7,020 points

Related Questions In Database

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
2,387 views
0 votes
1 answer

SQL count rows in a table

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

answered Feb 21 in Database by Neha
• 8,560 points
83 views
0 votes
1 answer

Find values in a comma separated string in a MySQL query

You can add commas to the left and ...READ MORE

answered Sep 10, 2018 in Database by Sahiti
• 6,380 points
11,386 views
0 votes
1 answer

Difference between single and double quotes in SQL

Single quotes are used to indicate the ...READ MORE

answered Sep 11, 2018 in Database by CodingByHeart77
• 3,720 points
14,340 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 in Database by Vaani
• 7,020 points
20 views
0 votes
1 answer

What is a stored procedure?

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

answered Feb 4 in Database by Neha
• 8,560 points
117 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 in Database by Neha
• 8,560 points
89 views
0 votes
1 answer

SQL Server: PARTITION BY vs GROUP BY

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

answered Feb 9 in Database by Neha
• 8,560 points
201 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 in Database by Vaani
• 7,020 points
57 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 in Database by Vaani
• 7,020 points
53 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP