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

How To Insert Or Add Emojis In Microsoft Teams Status Message

Pass GUID As Parameter To Action Using ASP.NET MVC ContribGrid