Folks,
Can't seem to find this anywhere. I have a table, say Table_A containing rows with UniqueIDs, and another table, say Table B, of identical structure containing more IDs. Some of these are the duplicated in Table_A, some are different. I want to update Table_A from Table_B....
Currently I can easily insert new records that are not in A
INSERT INTO TABLE_A
SELECT *
FROM TABLE_B
WHERE UniqueID NOT IN
(SELECT UniqueID
FROM TABLE_A)
But I can't find a similar way to do my update !
I could use an inner join and explicity
SET T1. Col1 = T2.Col1
...
T1.ColN = T2.ColN
WHERE T1.UniqueID = T2.UniqueID
But that will a) be messy (wide table) and b) require an update to the SQL if the table structures change. I would like something like the INSERT above to update the entire row automatically. Is there a simple SQL syntax for this....
Free Mince Pies for the neatest solutions...!!
------
Dublin, Ireland.
Can't seem to find this anywhere. I have a table, say Table_A containing rows with UniqueIDs, and another table, say Table B, of identical structure containing more IDs. Some of these are the duplicated in Table_A, some are different. I want to update Table_A from Table_B....
Currently I can easily insert new records that are not in A
INSERT INTO TABLE_A
SELECT *
FROM TABLE_B
WHERE UniqueID NOT IN
(SELECT UniqueID
FROM TABLE_A)
But I can't find a similar way to do my update !
I could use an inner join and explicity
SET T1. Col1 = T2.Col1
...
T1.ColN = T2.ColN
WHERE T1.UniqueID = T2.UniqueID
But that will a) be messy (wide table) and b) require an update to the SQL if the table structures change. I would like something like the INSERT above to update the entire row automatically. Is there a simple SQL syntax for this....
Free Mince Pies for the neatest solutions...!!
------
Dublin, Ireland.