SQL 2008 CASE statement aggravation...
- by Brad
Why does this fail:
DECLARE @DATE VARCHAR(50) = 'dasf'
SELECT CASE WHEN ISDATE(@DATE) = 1 THEN CONVERT(date,@DATE) ELSE @DATE END
Msg 241, Level 16, State 1, Line 2
Conversion failed when converting date and/or time from character string.
Why is it trying to convert dasf to date when it clearly causes ISDATE(@DATE) = 1 to evaluate to false...
If I do:
SELECT ISDATE(@DATE)
The return value is 0.