C# Tips

C# Tip Article

Tip: equivalent TSQL expression to string.IsNullOrEmpty()

In C#, we can check to see if a string is null or an empty string as follows.

if (string.IsNullOrEmpty(s))

Just for fun, what is the equivalent statement in T-SQL?

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

Likewise, !string.IsNullOrEmpty(s) can be written this way in T-SQL.

if isnull(@s, '') <> ''