May 14, 2010 at 3:04 am
Hi Everyone ,
I need to insert about 20 records to a database table.... Which is the better approach -
1) inserting one record at a time
2) concantening the insert queries using a semicolon and executing it as a batch
Regards
Sabarish
wwewew
May 14, 2010 at 3:18 am
2 , will leave you open to SQLInjection.
Please confirm your sqlserver version.
May 14, 2010 at 3:21 am
SQL Server 2005
wwewew
May 14, 2010 at 3:26 am
May 14, 2010 at 4:08 am
Thanks , i will have a look and get back
wwewew
May 14, 2010 at 4:38 am
sabarish (5/14/2010)
Hi Everyone ,I need to insert about 20 records to a database table.... Which is the better approach -
1) inserting one record at a time
2) concantening the insert queries using a semicolon and executing it as a batch
Regards
Sabarish
Neither is better, they are essentially the same.
Have you considered putting the 20 rows into a temp table or table variable and running as a single INSERT?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply