Luciano Evaristo Guerche

A brazilian geek interested in .NET technologies

About Me

June 2005 - Posts

BlogMapped! my blog

Folks,

Just subscribed to BlogMap! Unfortunately, I informed latitude -23.626111111111111111111111111111 and longitude -46.791666666666666666666666666667 and BlogMap! recorded latitude 24.9853391254525 and longitude -40.0293208384785 and now I am an Atlantic Ocean blogger resident. Can you believe that? I have already sent feedback to BlogMap! and hope they fix this bug soon.

Have you ever used BlogMap!? Drop me a line and let me know about.

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

More Posts