Hello,
I assume that table A has some id, so lets take example table A:
create table A (
id int not null,
atr1 int,
atr2 int,
loan char
)
go
now let's have some table B
create table B (
id int not null,
atr1b int,
atr2b int,
)
go
Now you can write SP for comparing desired attributes ( atr1 with atr1b .. and so on) for specified id
create proc sp_compare_a_b
@myid int
as
begin
declare @status int
declare @p1 int
declare @p2 int
set @status=0
select @p1=atr1 from a where id=@myid
select @p2=atr1b from b where id=@myid
if (@p1<>@p2) set @status=1
select @p1=atr2 from a where id=@myid
select @p2=atr2b from b where id=@myid
if (@p1<>@p2) set @status=1
-- ... and so on for each attribue you wan
-- and at the end lets do the update
if (@status=0)
update a set loan='Y' where id=@myid
else
update a set loan='N' where id=@myid
end
If you execute
exec sp_compare_a_b 3
it will check the attributes for id 3 and update accordingly the loan column
best regards
Chris