Good morning to everyone s,
SQL Server 2003 R2
I need to copy data from one table to another but only data fields are called exactly the same.
tabla_A fields: field1, field2, field3, field4, campo5, campo6
talba_B fields: field2, field3, field4, campo5, field8, campo9
You need to copy data from field2, field3, field4 and campo5 of tabla_A in tabla_B, a new record
although obviously do not know the names of all fields since they are hundreds, I just need to know what are called exactly the same and copy data
I searched the code but I have not found
thanks in advance
Answers
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
Please, How would the code?
This was my code:
INSERT INTO tabla_A
SELECT campo2 campo3,campo4,campo5
FROM tabla_B
WHERE tabla_B.[Document Type]=5
and tabla_B.No_ like '%0004'
and tabla_B.[Version No_]=2
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
yes but I do not know as used in sql
Blog - rockwithnav.wordpress.com/
Twitter - https://twitter.com/RockwithNav
Facebook - https://facebook.com/rockwithnav/
In summary you would want to...
For each record of one table enumerate the fields, search their name buddies in the receiving table, assign if found (FieldRef2.VALUE := FieldRef1.VALUE). When done processing all the fields insert the record.