How do you check for NULL
in a CASE
statement, when you're using a Scalar Function
?
My original query was ... but it fails
SELECT CASE dbo.fnCarerResponse('') WHEN NULL THEN 'Pass' ELSE 'Fail' END
I read the SO question about using IS NULL
, like so ...
SELECT CASE dbo.fnCarerResponse('') IS NULL WHEN NULL THEN 'Pass' ELSE 'Fail' END
but this gives the incorrect syntax near the keyword is
error
Can you have a Scalar Function
in the CASE
?
You are using the wrong style of CASE
- you need to use CASE WHEN <expression> THEN
not CASE <expression> WHEN <expression> then
:
SELECT CASE WHEN dbo.fnCarerResponse('') IS NULL THEN 'Pass' ELSE 'Fail' END
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With