Hi,
How to insert multiple records in a single statement? what are the possible ways?
Thanks.
Sql insert statement
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Apr 5, 2012, 6:54 AM EDT
However, for SQL Server, I'd check the examples in this link:
http://msdn.microsoft.com/en-us/library/ms174335.aspx
SenthilkumarRank #387 · 6.5K reputationPosted Apr 5, 2012, 7:12 AM EDT
There are lot of ways in sql server.
1) If you are trying to insert from the selected records then
INSERT INTO tmpProducts(tProductID, tProductName, tManfacturer )
SELECT DISTINCT ProductID, ProductName, Manfacturer FROM Products
2) You can use the derived table to insert multiple records
SELECT * INTO #tmpProducts FROM Products
3) From sql server 2008 onwards
4) Using the union all
INSERT INTO MyTable (FirstCol, SecondCol)