Null or empty check for a string variable

Bharath picture Bharath · Apr 18, 2013 · Viewed 155.7k times · Source
if((isnull(@value,''))='')

I want to know whether the above piece of code works in checking if the variable is null or empty.

Answer

Guffa picture Guffa · Apr 18, 2013

Yes, that code does exactly that.

You can also use:

if (@value is null or @value = '')

Edit:

With the added information that @value is an int value, you need instead:

if (@value is null)

An int value can never contain the value ''.