I have this code in my select statement
ISNULL(a.PolicySignedDateTime,aq.Amount) AS \'Signed Premium\',
But I want to see if \"a.PolicySign
It seems to me this would be an easy way to get the opposite.
SELECT (1-ISNULL(field));
Will give you 1 if NOT NULL and 0 if NULL instead of the 1 for NULL and 0 for NOT NULL
There is no opposite function but you can do it without CASE
.
Use the fact that a string + 'something' will be NULL if string is NULL, and if that is null then use ISNULL to return 'somethingelse', get end of the returned value with RIGHT() and check that against 'something' using NULLIF, and then use COALESCE to do what you'd like to do if that is NULL (meaning original value is not null).
Example:
declare @text varchar(20) = 'some text or value'
select COALESCE(NULLIF(RIGHT(ISNULL(@text + 'NOT', 'IS ') + 'NULL', 7), 'NOTNULL'), 'NOT NULL')
Try this code and also try it with no value for @text.