Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Appending insert queries using semicoln Expand / Collapse
Author
Message
Posted Friday, May 14, 2010 3:04 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 29, 2010 3:04 AM
Points: 12, Visits: 22
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
Post #921847
Posted Friday, May 14, 2010 3:18 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
2 , will leave you open to SQLInjection.

Please confirm your sqlserver version.




Clear Sky SQL
My Blog
Kent user group
Post #921856
Posted Friday, May 14, 2010 3:21 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 29, 2010 3:04 AM
Points: 12, Visits: 22
SQL Server 2005


wwewew
Post #921858
Posted Friday, May 14, 2010 3:26 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
Please see this link

http://www.sommarskog.se/arrays-in-sql-2005.html




Clear Sky SQL
My Blog
Kent user group
Post #921860
Posted Friday, May 14, 2010 4:08 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 29, 2010 3:04 AM
Points: 12, Visits: 22
Thanks , i will have a look and get back


wwewew
Post #921886
Posted Friday, May 14, 2010 4:38 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 1:43 AM
Points: 6,890, Visits: 14,254
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?


“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

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
Exploring Recursive CTEs by Example Dwain Camps
Post #921898
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse