Donate

How To Check If SQL Server Column Is Null Or Empty

Hello fellow programmers!

Here's a simple T-SQL statement that will check if a column value is null or empty.
IIF(c.BillPhone is null, '', IIF(Len(c.BillPhone) > 0, c.BillPhone ,'')) as BillingPhone
First, it will check if the field is null. If true, it will return empty string. Else, another checking will be performed and this time if it's an empty string. If not an empty string, show the column value. Else show an empty string.

That's it! :-)

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

Remove Cookies From CookieContainer Class

How To Test Or Check Dead Pixels And Backlight Bleed On Your Monitor Using Dead Pixel Checker In Windows 11