Q:

Combine two columns in the ON search condition of MERGE sql server

I have two date columns, [START DATE] and [END DATE] and I want to only insert records whose dates are not in either column. This is what my logic looks like: 
MERGE TABLE_A                                      AS Target
USING (SELECT DISTINCT * FROM TABLE_B)             AS Source
ON (SELECT Target.[START DATE] + Target.[END DATE] AS Target.[COMPAREDATE] = 
    SELECT Source.[START DATE] + Source.[END DATE] AS Source.[COMPAREDATE]) 
WHEN NOT MATCHED THEN
INSERT ([DATE ADDED], [END DATE], ...)
VALUES (Source.[DATE ADDED], Source.[END DATE], ...);

I also tried the code below but it continued to insert duplicates:
ON (Target.[START DATE] = Source.[START DATE] AND Target.[END DATE] = Source.[END DATE])

I'd appreciate any help, thanks!

A:

This code was close:
ON (Target.[START DATE] = Source.[START DATE] AND Target.[END DATE] = Source.[END DATE])

It says, "if both the StartDate and the EndDate match, then the rows match".
If you want to say "if either the StartDates match or the EndDates match, then the rows match", then you should do this:
ON (Target.[START DATE] = Source.[START DATE] OR Target.[END DATE] = Source.[END DATE])

