Check for empty string in SELECT statement - SQL

In this post, I describe how to check for empty string in the SELECT statement in SQL.

Screenshot of a SELECT statement in SQL which checks for an empty string

Resolution

To check for an empty string in the SELECT statement in SQL, use ISNULL and NULLIF:

SELECT ISNULL(NULLIF(s.[Name], ''), 'None') [Name]
FROM [Sales].[Store] s

In this example. if the Store Name is empty, NULLIF will return null.

If NULLIF returns null, ISNULL will show the value 'None'.

Comments

Popular posts from this blog

LG TV This app will now restart to free up more memory

LG TV Clear All Browsing History Data

LG TV turn off Quick Start in settings