Q: What is the sound of one value coalescing?
-
A: It goes BOOM! SQL Server 2008 R2 I was just altering some of my code to choose betewen two values via COALESCE. Then I decided I might want to back out the change, but I wanted to leave the existing code in case I wanted to reapply the change later. So I had something like
COALESCE ( /* X , */ Y ) Z
-- of course, it makes no sense to COALESCE on one value, but I was only going to leave it there momentarily and I don't mind causing errors in order to advance my knowledge of the syntax. The result isIncorrect syntax near ')'.
-- I thought that was an odd message. I checked the documentation:COALESCE ( expression [ ,...n ] )
-- so the syntax should be legal! :wtf: But it also goes on to say that COALESCE is equivalent to a CASE and my attempts atCASE (WHEN Y IS NOT NULL) THEN Y END Z
CASE ELSE Y END Z
have been unsatisfactory. :sigh: