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

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


You have to use CASE

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


I know is late but just in case someone else viewing this and using MSSQL 2012 or above you could use 'IIF' statement.

I guess OP don't want to use 'IF' clausule cause is "too much code syntax" to acomplish simple stuff.

An alternative also cleaner than 'IF' statement is 'IIF'. Is just an inline 'IF' simplification.

SELECT IIF(X IS NULL, 'Is null', 'Not null') 'Column Name'

Regarding OP

SELECT IIF(a.PolicySignedDateTime IS NULL, NULL, aq.Amount) AS 'Signed Premium'

https://docs.microsoft.com/en-us/sql/t-sql/functions/logical-functions-iif-transact-sql?view=sql-server-ver15


There is the COALESCE expression (although not function https://msdn.microsoft.com/en-us/library/ms190349.aspx) test the arguments in order and keep doing it until finds the value not NULL and returns it.

example usage:
SELECT COALESCE(NULL, NULL, 5)--returns 5

In your case :
COALESCE(a.PolicySignedDateTime,aq.Amount) AS 'Signed Premium',