Solved

multiple inserts

Posted on 2002-05-24
2
160 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now