Copying from table to table

  • Thread starter Thread starter poppy
  • Start date Start date
P

poppy

I have a dataset which has 1 table with 10 coloumns and n
rows.

I create a new table "newTable" which contains 2
columns "A" and "B".

I want to copy the contents of col 7 and col 8 of the
original dataset/table into "newTable".

Whats the most efficient way of doing this ?

Coming up with a refined way of doing this is important
as I perform this operation often in my application.
 
Whats the most efficient way of doing this ?

If creating a new table:

SELECT * INTO TABLE FROM OLDTABLE

OR if appending data into an existing table:

INSERT INTO TABLE (SELECT FROM ...)
 
Coming up with a refined way of doing this is important
as I perform this operation often in my application.

BTW, if you're archiving data alot... it maybe better to flag the records
with a bit field instead of phyiscally moving them.
 
poppy said:
I have a dataset which has 1 table with 10 coloumns and n
rows.

I create a new table "newTable" which contains 2
columns "A" and "B".

I want to copy the contents of col 7 and col 8 of the
original dataset/table into "newTable".

Whats the most efficient way of doing this ?

Coming up with a refined way of doing this is important
as I perform this operation often in my application.

I would use something along the lines of:

For each row in oldtable
newrow.item(0) = row.item(7)
newrow.item(1) = row.item(8)
newtable.insert(newrow)
next row
 
Is a new table necessary?

Why not use a view on the the old table.

SELECT col7 AS col1, col8 AS col2 FROM oldTable

Resulting dataset looks for all the world like a table.

Brian Lowe
---------@
 
Back
Top