Click to See Complete Forum and Search --> : copying a recordset
Nathan
Aug 21st, 2000, 02:37 PM
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...
parksie
Aug 21st, 2000, 02:40 PM
Have a look at the Clone method.
Nathan
Aug 21st, 2000, 03:16 PM
looked at it... doesn't work for what I need...
thanx anyway.
BruceG
Aug 21st, 2000, 04:15 PM
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;
Nathan
Aug 22nd, 2000, 07:38 AM
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?
Clunietp
Aug 22nd, 2000, 08:55 AM
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.
Nathan
Aug 22nd, 2000, 11:41 AM
works great thanx!
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.