Bobby Bobby - 29 days ago 12
SQL Question

Is there a opposite function to ISNULL in sql server? To do Is not null?

I have this code in my select statement

ISNULL(a.PolicySignedDateTime,aq.Amount) AS 'Signed Premium',


But I want to see if "a.PolicySignedDateTime" is not null.
Is there a easy function to do this which does not involve using a "if" statement?

Cheers guys

Answer

You have to use CASE

SELECT CASE WHEN Field IS NOT NULL
    THEN 'something'
    ELSE 'something else'
END