VB.NET - Copy column from one table to another

Asked By david rony on 08-Sep-13 04:37 PM
I have 2 tables as below. I am having trouble to copy column from table1 to table2 in vb.net and ms access.I am trying the following sql query but getting syntax error . Insert into table2 (C) select C from table1 Can someone please help me table1 Col A|col C 100|200 400|500 Table2 Col A|col B|col C 10|20| 30| 40|50| 60| I want to query (sql) to retrieve result as below. Col A|col B|col C 10|20| 200 40|50| 500
Reena Jain replied to david rony on 10-Sep-13 02:31 AM
hi,

use the following query to fill the data from one table to another table

  • if want to copy some fields only or fields are different of both table
Insert into Database2.Table2 (field1, field2) select field1, field2
from Database2.Table1

  • if want to copy all fields  or fields are same of both table
Insert into Database2.Table2  select * from Database2.Table1

Ref: - https://www.nullskull.com/q/10255861/to-copy-records-of-one-table-into-another.aspx
https://www.nullskull.com/q/10130678/update-complete-row-from-one-table-to-another.aspx

Hope this will help you