I have the below query to be re-written without using the IsNull operator as I am using the encryption on those columns and IsNull isn't supported
I suppose you mean that columns c.email1
and E.email
are never null, but they sometimes contain encrypted strings that convey the absence of data in a manner similar to that ordinarily conveyed by a NULL. For example, maybe the encrypted form of an empty string is used. In that event, you can compare their values to the encrypted null-equivalent:
Case
When Indicator = 'N' Then Null
when c.email1 != 'some-encrypted-string-equivalent-to-null' then c.email1
when E.email != 'some-encrypted-string-equivalent-to-null' then E.email
else ORG_Email
End EmailAddress
Of course, that assumes that there is a single null-equivalent string, at least on a per-column basis, which might not be the case. If it isn't then the only options I see are
decrypt the e-mail values in the query (possibly via a user-defined function) and write the conditions based on the decrypted values, or
return both the encypted c.email1
and E.email
as separate columns, or null for both if Indicator
is 'N'
, and select which one to use on the application side, after decryption.