ISNULL + NULLIF instead of CASE WHEN
Today I had to write a SQL statement quite similar to the sample below:
SELECT ProductID,
ProductName,
CASE WHEN ProductDescription IS NULL OR ProductDescription = ''
THEN '<no description>'
ELSE ProductDescription END AS ProductDescription
FROM Products
ORDER BY ProductName
Then I changed it, replacing CASE WHEN by ISNULL and NULLIF, as can be seen below:
SELECT ProductID,
ProductName,
ISNULL(NULLIF(ProductDescription, ''), '<no description>') AS ProductDescription
FROM Products
ORDER BY ProductName
What do you think about this kind of construction. Drop me a line and let me know what your feelings about