Quantcast
Channel: Solved » sql-server
Viewing all articles
Browse latest Browse all 48

How Do I Check if a Sql Server String Is Null or Empty

$
0
0

if((isnull(@value,''))='')

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

Solution

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 ''.

The post How Do I Check if a Sql Server String Is Null or Empty appeared first on Solved.


Viewing all articles
Browse latest Browse all 48

Trending Articles