Mssql case when multiple conditions in case

These expressions can obviously yield a different value if evaluated multiple times.

mssql case when multiple conditions in case

June 16, 2014 at 1: Email Required, but never shown. June 13, 2014 at 10: You can't edit your own events.

June 16, 2014 at 9: I was first made aware of this specific scenario in a conversation on a private e-mail distribution list by Itzik Ben-Gan ItzikBenGan , who in turn was initially notified by Jaime Lafargue. Joel says: SQL Editor.

mssql case when multiple conditions in case

So do we. Combining all conditions select a.

CASE (Transact-SQL)

October 24, 2016 at 12: So we skip that clause and move on. Sign up here and we'll keep you posted:. Their algorithms leave something to be desired. Only one of your four possible outputs would appear on any one row.

Dirty Secrets of the CASE Expression

ArtNo, p. Mode Business Blog Forum. IIF is a function that I expected to fall into this same trap, but this function is really just a searched CASE expression with only two possible outcomes, and no ELSE — so it is tough, without nesting and introducing other functions, to envision a scenario where this can break unexpectedly.

mssql case when multiple conditions in case

One of the few limitations of the CASE expression is that is restricted to 10 nest levels. I don't have a repro handy, but I do believe him, and I don't think we've unearthed all of the edge cases where this may occur. You can't post HTML code. If these expressions are equivalent, the expression in the THEN clause will be returned.