Suggestions for batch insert

I have to build 1 table from variables in another.  There's allot of logic being applied from the first table so it's not a simple insert.  The problem is doing this mytable, ...

while not rsSource.eof
   lots of logic
   rsDest.field1 = rsSource.field1
   ... ....


just takes too long with 20,000 records. What would be some faster ways to do this?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

What exactly is the database? Access or SQL Server or something else?

Assuming you do this import in frontend like you are doing now, you can increase the speed many times by not using the recordset to update but instead using the Execute method of connection object to directly execute SQL Insert or Update statement. Something like this:

while not rsSource.eof
   lots of logic
   strSQL = "Insert into TableName Values('" & rsSource.field1 & "')"
   objConnection.Execute strSQL

If u are on SQL Server then DTS will be the fastest way to do the necessary import.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.