Hello,
I have two identical tables (same structure) but one table is more up to date of the other one.
I would like to tableA.date = tableB.date update the tableB.value if the tableA.value <> tableB.value for tableA.date = tableB.date
So I would like to do if it is possible :
if ( (tableA.value from tableA where tableA.date= '2005-06-30' and tableA.code = 12 and tableA.country = 'US' and tableA.ST = 'NY') = (select tableB.value from tableB where table.date = '2005-06-30' and tableB.code= 1303 and tableB.Code = 'NY ' and tableB.Country = 'US'))
print 'not updated'
else
UPDATE tableB
SET tableB.value = (
select value
from tableA
where tableA.Country = 'US' and tableA.code = 12 and tableA.ST = 'NY' )
WHERE tableB= 12 and tableB.ST = 'NY' and Country = 'US'
My question how to iterate this operation.
With a cursor? or a while? I would like to update all values in tableB which are different from values in table B for the same date.
Any suggestions,
Ina
I have two identical tables (same structure) but one table is more up to date of the other one.
I would like to tableA.date = tableB.date update the tableB.value if the tableA.value <> tableB.value for tableA.date = tableB.date
So I would like to do if it is possible :
if ( (tableA.value from tableA where tableA.date= '2005-06-30' and tableA.code = 12 and tableA.country = 'US' and tableA.ST = 'NY') = (select tableB.value from tableB where table.date = '2005-06-30' and tableB.code= 1303 and tableB.Code = 'NY ' and tableB.Country = 'US'))
print 'not updated'
else
UPDATE tableB
SET tableB.value = (
select value
from tableA
where tableA.Country = 'US' and tableA.code = 12 and tableA.ST = 'NY' )
WHERE tableB= 12 and tableB.ST = 'NY' and Country = 'US'
My question how to iterate this operation.
With a cursor? or a while? I would like to update all values in tableB which are different from values in table B for the same date.
Any suggestions,
Ina