Copying from table to table

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.
 
L

Lucas Tam

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 ...)
 
L

Lucas Tam

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.
 
B

Brian Barnes

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
 
B

Brian Lowe

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
---------@
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top