Results 1 to 7 of 7

Thread: [RESOLVED] Batch insert into DB?

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    Resolved [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.

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    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.

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    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.

  5. #5
    Frenzied Member
    Join Date
    Feb 2003
    Location
    Argentina
    Posts
    1,950

    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

  6. #6
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  7. #7

    Thread Starter
    Fanatic Member
    Join Date
    Aug 2005
    Location
    Up State NY
    Posts
    525

    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
  •  



Click Here to Expand Forum to Full Width