+1 vote
1 view
in SQL by (22.4k 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.3k 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’);

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...