If you compare two values and either of them can be null or one of them null equal (=) operator does not work. Equal operator is not null sensitive. To compare the two you have to changed null to valid string value and then apply = operator.
declare @v1 varchar(20)
declare @v2 varchar(20)
if (isnull(@v1,'0') = isnull(@v2,'0'))
select 'Match Found'
else
select 'Match not found'
The above code demonstrates the correct way of comparing null values.
if (@v1 = @v2)
select 'Match Found'
else
select 'Match not found'
the above code will always return false if either end is null or both ends are null. Therefore this is wrong syntax.
If you are comparing more than oen value between two tables, you can use SQL Intersect as well