Solved

multiple inserts

Posted on 2002-05-24
2
163 Views
Last Modified: 2013-12-24
I'm using cf 5 to run a scheduled task which retrieves a csv. I then parse the csv file and insert records into a database. The problem is that there are about 30,000 entries in the csv which means looping over and doing 30,000 inserts.

Is there a way to insert multiple records in one sql command.

I'm using sql server 7.
0
Comment
Question by:jamathon
2 Comments
 
LVL 23

Accepted Solution

by:
Racim BOUDJAKDJI earned 200 total points
ID: 7037180
jamathon,

When running batch processes, your basically make numerous round trips between your Applicative Server (Cold Fusion) and your Data Source (either a database server or a file).  It is an unefficient consumption of bandwith ressources.  

The best way to do what you're asking is to parse all data at once (or break it into 8000 bytes chunks) then let the SQL Server do the looping (and even the reading) for you into one stored procedure.  To do that, you will probably need to familiarize yourself with cursors concepts (they will give you the capability to control more sharply your iteration).  As you have only one round trip between you will be surprised how faster that can be.

Another way to do it may be to a read by SQL Server then attach the data from the CSV if the structure is similar to the table that contains the data.  Hope this helped...

Sincerely,

Racimo
0
 
LVL 2

Author Comment

by:jamathon
ID: 7037679
Thanks,

I got it sorted over the weekend by using the DTS wizard on SQL server, and then used a CF script to call a stored procedure which starts the process.
The 30,000 records where taking 8 minutes, they now take about 8 seconds.

As this is now reolved I'll give u the points

cheers

James
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

805 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question