How to check if a string is null or empty in SQL Server
June 1, 2015
The most elegant and simple solution I have come across and use is:
SELECT
ISNULL(NULLIF(VALUE_TO_CHECK, ''), FAILED_VALUE) AS [Your Alias]
FROM ...
VALUE_TO_CHECK is used if the string is not null or empty and the FAILED_VALUE is used if it is.
Tags: SQL
Back to Posts