I have two tables with the same structure but I have to compare their contents to find differences. The records with differences I get back correctly but I would like to know if you can get back the columns that have different value.
declare @tabla_original table (campo1 int, campo2 varchar(15), campo3 varchar(15))
insert into @tabla_original values (1, 'uno','A')
insert into @tabla_original values (2, 'dos','B')
insert into @tabla_original values (3, 'tres','C')
insert into @tabla_original values (4, 'cuatro','D')
declare @tabla_final table (campo1 int, campo2 varchar(15), campo3 varchar(15))
insert into @tabla_final values (3, 'tres','C')
insert into @tabla_final values (2, 'dos','B')
insert into @tabla_final values (1, 'uno','C')
insert into @tabla_final values (44, 'cuatro','D')
select * from @tabla_final
except
select * from @tabla_original
In this test records 1 and 4 are different. The 4 in the final_table does not exist but the 1 has a difference in the field3. What I would like is for me to return that the field3 is the one that has the difference.