Two NULL values comparision

Posted by Bandi under Sql Server category on | Points: 40 | Views : 227
If we are comparing two NULL values against the Equal or NOT Equal operators, what will be the ouput?

what will be the output for below code?

declare @v2 varchar(10);
declare @v1 varchar(10);
IF @v1 = @v2
Print 'EQUAL';
else if @v1 != @v2
Print ' NOT EQUAL';
Print ' Neither EQUAL nor NOT EQUAL';

Comparison against NULL values will results NULL, but not the TRUE/FALSE..
So the output of the above code will be 'Neither EQUAL nor NOT EQUAL'

Comments or Responses

Login to post response