merge null values in the merge command

NULL is a special case in any RDBMS.

When you write below condition in WHEN MATCHED clause:

SOURCE.[is_correspondence_address] <> TARGET.[is_correspondence_address] OR 

it is not considering NULL for comparison – any comparison with NULL results into NULL.

If you want to handle NULL in comparison, you can write below clause (assumming is_correspondence_address is VARCHAR/NVARCHAR datatype):

    ISNULL(SOURCE.[is_correspondence_address],'NOTDEFINED') 
      <> ISNULL(TARGET.[is_correspondence_address], 'NOTDEFINED') OR

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top