Column, Variable Comparision with null value

If you compare any column or variable with null value then it always return null value.

For example

if you declare a variable

declare @val1 int

declare @val2 int

set @Val2 =1

at this time @val1 is null

if @Val1<>@Val2

print ‘No Match’

the @Val1=null; @Val2=1; on seeing it you say val1 not equal to val2 but actually the code execution skips this…. beware 🙂

The print ‘No Match’ will never be executed if you manually set initial value

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s