I want a SQL query to return "VIDE" when the field is empty in Sales Cloud but I have an error message saying "Incorrect syntax near the keyword 'IF'.
Here is my SQL part : IF NULL (Code_Provenance__c, 'VIDE') as 'CODE_PROVENANCE',
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.Sign up to join this community
There are a few ways to resolve this (I know you mentioned in your comments that you utilized CASE to solve for it, but thought i should leave something as a reference for anyone else having this issue):
SELECT primarykey, CASE WHEN field1 IS NULL THEN 'Default Value' ELSE field1 END as field1 FROM [myDE]
SELECT primarykey, ISNULL(field1,'Default Value') as field1 FROM [myDE]
SELECT primarykey, COALESCE(field1,'Default Value') as field1 FROM [myDE]
There may be a couple other ways to accomplish this, but these are three should handle most if not all use cases you may have.