Answer Q no 2

Answer Q no 2

Correct Answer:

INSERT dbo.mytable (col1, col2) VALUES (‘Test’, ‘Test2’), (‘Test3’, ‘Test4’), (‘test5’, ‘test6’);

You can use the Transact-SQL row constructor (also called a table value constructor) to specify multiple rows in a single INSERT statement. The row constructor consists of a single VALUES clause with multiple value lists enclosed in parentheses and separated by a comma. For more information, see Table Value Constructor (Transact-SQL).

Back to Question

Question no 2

Question no 2

In SQL Server 2008 R2, if I want to insert multiple rows in one statement, which format should I use?

1. INSERT dbo.mytable (col1, col2) VALUES (‘Test’, ‘Test2’), (‘Test3’, ‘Test4’), (‘test5’, ‘test6’);

2. INSERT dbo.mytable (col1, col2) SELECT (‘Test’, ‘Test2’), (‘Test3’, ‘Test4’), (‘test5’, ‘test6’);

3. INSERT dbo.mytable (col1, col2) VALUES ((‘Test’, ‘Test2’), (‘Test3’, ‘Test4’), (‘test5’, ‘test6’));

4. INSERT dbo.mytable (col1, col2) VALUES [(‘Test’, ‘Test2’), (‘Test3’, ‘Test4’), (‘test5’, ‘test6’)];

Go To The Answer