Results 1 to 7 of 7

Thread: copying a recordset

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    I was wondering if anyone knew if it is possible to copy a recordset or a row from a recordset to another recordset or row of a recordset. Clear as mud? For example... I have a dBase database and I want to copy a bunch of rows from one of the dbase tables to a sql server database table. what is the fastest way to do this.. any ideas? right now I have it looping through every field of every row and copying everything field by field... there has to be a faster way to do this...


  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Have a look at the Clone method.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    looked at it... doesn't work for what I need...
    thanx anyway.

  4. #4
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    I would use the INSERT INTO SQL statement with the SELECT option. Examples:

    (1) For cases where the destination table has the same number of fields (and compatible datatypes) as the source table, you can use:
    INSERT INTO DestinationTable SELECT * FROM SourceTable;

    (2) For cases where the number of fields are different, or are in a different order, etc., you can use this variation:
    INSERT INTO DestinationTable (DestField1, DestField2, etc.) SELECT SourceField3, SourceField4, etc. FROM SourceTable;
    "It's cold gin time again ..."

    Check out my website here.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    Thanx, I've been trying that, but my problem is one table is from a dbase database and the other table that I want to copy to is in a sql server database. Any ideas?

  6. #6
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Create a new recordset on the fly and populate it with your data. Then connect to SQL server, loop through the new recordset, and use SQL INSERT INTO statements.

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    188
    works great thanx!

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