|
-
Apr 11th, 2007, 10:36 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Batch insert into DB?
I created a recordset from one table/DB Is there a way to append this data to another table/DB in a batch load with out single stepping through the recordset? (read/insert, movenext, read/insert)
Table definitions are exactly the same.
-
Apr 11th, 2007, 11:36 AM
#2
Re: Batch insert into DB?
The most efficient way is not to use a recordset at all, but simply transfer all the data you want with a single SQL statement (assuming that it is supported by your database system(s)).
What are the database systems on each end?
It would probably help us to see the table definition too.
-
Apr 11th, 2007, 11:51 AM
#3
Thread Starter
Fanatic Member
Re: Batch insert into DB?
Oracle 8i to Sequel Server 7. I created the tables exactly (well as much as possible) for a datamart as the network is slow here.
-
Apr 11th, 2007, 12:06 PM
#4
Re: Batch insert into DB?
I haven't use Oracle enough to know what functionality it provides, and SQL Server 7 is before my time (I've mainly used 2000).
If this is a one-off job then it would be worth looking in Enterprise Manager to see if there is functionality to import the data (presumably via DTS).
If it is going to happen regularly it would probably be best to treat the Oracle system as a Linked Server, but I'm afraid you'll need to look into the documentation for how this works on SQL Server 7.
If that doesn't help, I'm guessing the best way would be to disconnect the recordset and re-connect it to the other server (hopefully somebody will post to say how!), otherwise for a (minor?) speed improvement you can use the batch update functionality of ADO, as seen here.
-
Apr 11th, 2007, 08:28 PM
#5
Frenzied Member
Re: Batch insert into DB?
One idea I came up with when I couldn't figure out a query to do what I wanted was to loop through recordsets to build a string with the data wanted, create a text file, and then import that file.
I don't know if that was the best solution, but it was a lot faster than running K's of INSERT statements. Plain SQL would've been better, but like I say, never figured out a way to do it.
Tengo mas preguntas que contestas
-
Apr 11th, 2007, 09:12 PM
#6
Re: Batch insert into DB?
Two words: BULK INSERT....
Another technique I've used... is to create a disconnected recordset, add everything to it, then use the UpdateBatch method to send all the changes to the database.
-tg
-
Apr 12th, 2007, 07:07 AM
#7
Thread Starter
Fanatic Member
Re: Batch insert into DB?
The initial pull involved thousands of entries in multiple tables. Once done I am checking the datestamp of the reciever DB, checking the donor for any entries greater, then making a disconnected RS from the donor DB. Transfer and loop through the data. Done every 1/2 hour, keeps transfer size low, server loading minimal and data fairly up todate.
Thanks for the help guys!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|