Using SQL Server 7 (very soon 2000)!
I have two tables (a & b) that have the same key (a.key, b.key) and a few of the same fields (a.checksum, b.checksum). I'm trying to compare the records in these tables, and wherever the same keys do not have matching checksum fields, then I would like to update the B table rows, with the corresponding A table row data.
Below is the sql I am using which works if only 1 record is different between the two tables, but crashes when there are multiple records found.
update b
set b.checksum = (select a.checksum from a,b
where a.checksum != b.checksum
and a.key = b.key)
where b.key in
(select b.key from a, b
where a.checksum != b.checksum
and a.key = b.key);
Any suggestions or help is much appreciated!!!
Thanks,
Mike Long
I have two tables (a & b) that have the same key (a.key, b.key) and a few of the same fields (a.checksum, b.checksum). I'm trying to compare the records in these tables, and wherever the same keys do not have matching checksum fields, then I would like to update the B table rows, with the corresponding A table row data.
Below is the sql I am using which works if only 1 record is different between the two tables, but crashes when there are multiple records found.
update b
set b.checksum = (select a.checksum from a,b
where a.checksum != b.checksum
and a.key = b.key)
where b.key in
(select b.key from a, b
where a.checksum != b.checksum
and a.key = b.key);
Any suggestions or help is much appreciated!!!
Thanks,
Mike Long