473,320 Members | 1,951 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Copying from table to table

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.
Nov 18 '05 #1
5 1247
"poppy" <an*******@discussions.microsoft.com> wrote in news:643301c49365
$0****************@phx.gbl:
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 ...)
--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #2
"poppy" <an*******@discussions.microsoft.com> wrote in news:643301c49365
$0****************@phx.gbl:
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.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #3
THe table I am refering to is not a database table. It is
a table from ado.net.
Nov 18 '05 #4
"poppy" <an*******@discussions.microsoft.com> wrote in message
news:64****************************@phx.gbl...
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

--
Brian Barnes
No Spam Proof e-mail
Use News Groups
Nov 18 '05 #5
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
---------@

"poppy" <an*******@discussions.microsoft.com> wrote in message
news:64****************************@phx.gbl...
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.

Nov 18 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jason | last post by:
In enterprise manager I am copying a table from one database to another. I am using the dts wizard to import the data. After I successfully import the data, I open both tables to compare the...
1
by: boonkit | last post by:
I try to get better performance by implementing this: http://dev.mysql.com/doc/mysql/en/alter-table.html "ORDER BY allows you to create the new table with the rows in a specific order. Note...
2
by: Praveen | last post by:
Hi, Is there a way to copy over a table's properties and styles (NOT it's child elements like tbody, trs, etc) into another table, besides doing them manually, one by one? Thanks Praveen
4
by: zMisc | last post by:
Is it possible to copy a table from one schema to another schema by just copying the frm file to the directory for the new schema? What is the best way to create a new database with all the...
1
by: syvman | last post by:
Hi all... I've been trying to copy a VFP table into an Access database and I haven't had much success... The code I'm using below (Access VBA) returns a "Syntax Error" in the SQL statement. If I...
4
by: =?Utf-8?B?RGFuaWVs?= | last post by:
Hello Can you please give me a sample code on how to copy a Table into a clipboard using vb.net Thank you
5
by: mark_aok | last post by:
Hi all, I have a situation where I have a split database. At the back end, I need to - create a new table (I will call it newTable) with the exact fields, and relationships as another table...
6
by: AshleyB | last post by:
2 phpbb boards I run have been hacked. One I've restored but the other one has had some damage to the MySQL db. A table is missing. As it's a styles table I thought I could could copy a table,...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.