I had to develop a solution to compare table structures and run a procedure to import the difference between the tables.
I used below code to select the data
--> table structures
create table #table1 (
campo varchar(10)
,campo1 varchar(10)
)
create table #table2 (
campo varchar(10)
,campo1 varchar(10)
)
--> Insert values
insert into #table1 values ('bruno',1)
insert into #table1 values ('bruno',2)
insert into #table2 values ('bruno',1)
insert into #table2 values ('bruna',2)
--> Create a hash column to compare
select *,HASHBYTES('SHA1', (select z.* FOR XML RAW)) as hash
into #compare1
from #table1 z
select *,HASHBYTES('SHA1', (select k.* FOR XML RAW)) as hash
into #compare2
from #table2 k
--> check the lines that has any difference
select * from #compare1 a
full outer join #compare2 b on a.hash = b.hash
where ( a.hash is null or b.hash is null )
Maybe this is useful for someone needing the same thing
Find code explaned above here