Back

Explore Courses Blog Tutorials Interview Questions
+1 vote
2 views
in SQL by (20.3k points)

I have multiple set of data to insert at once, say 4 rows.

My table has three columns: Person, Id and Office.

INSERT INTO MyTable VALUES ("John", 123, "Lloyds Office");

INSERT INTO MyTable VALUES ("Jane", 124, "Lloyds Office");

INSERT INTO MyTable VALUES ("Billy", 125, "London Office");

INSERT INTO MyTable VALUES ("Miranda", 126, "Bristol Office");

Can I insert all 4 rows in a single SQL statement?

1 Answer

+5 votes
by (40.7k points)
edited by

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

Are you interested in learning SQl from scratch! Have a look at this interesting video on SQL provided by Intellipaat:

Syntax:

INSERT INTO Table_Name(Col_Name)VALUES(Value_Name) 

If you want to insert into a single table, then you can write the code like this:

INSERT INTO TableA (Col_First, Col_Last)

VALUES (‘James’, ‘Jonas’), (‘Jack’, ‘Jonas’), (‘Robert’, ‘Jonas’);

Browse Categories

...