What I think is that IS NULL is just being checked against the function output, whether it is an error code or a true value.
If you check the same against the NOT NULL, then it gives the correct results. for example
SELECT CASE WHEN ACOS(2.3) IS NOT NULL THEN 'T' ELSE 'F' END AS C0,
CASE WHEN ACOS(0.23) IS NOT NULL THEN 'T' ELSE 'F' END AS C1
To avoid an error value to be checked and return an error instead of blind check, you can use a derived table as below:
SELECT TOP 2 CASE WHEN DRV.A IS NULL THEN 'T' ELSE 'F'
END AS C0
FROM
(
SELECT ACOS(0.23) AS A
)DRV;
What I think is that IS NULL is just being checked against the function output, whether it is an error code or a true value.
If you check the same against the NOT NULL, then it gives the correct results. for example
SELECT CASE WHEN ACOS(2.3) IS NOT NULL THEN 'T' ELSE 'F' END AS C0,
CASE WHEN ACOS(0.23) IS NOT NULL THEN 'T' ELSE 'F' END AS C1
To avoid an error value to be checked and return an error instead of blind check, you can use a derived table as below: