Conditional Split fails if value is NULL in SSIS

InTheWorldOfCodingApplications picture InTheWorldOfCodingApplications · May 21, 2013 · Viewed 49.8k times · Source

I am passing result of FULL Outer join to Conditional Split and Filtering Records on the basis of following rules . Basically both tables has same schema and Primarykey values are same.

a. If Primary key of Source is NULL
b. If Primary Key of Destination is NULL
c. If Source and Destination key matches. 

It works fine for (a) and (b) but fails for (c)

Source.Id == Destination.Id

and throws exception that condition evaluated as NULL where Boolean was expected. How i can make this work?

Conditional Split gets input from Merge Join and it's a FULL OUTER JOIN as i need FULL OUTER join results here

Answer

Milen Kindekov picture Milen Kindekov · May 21, 2013

Your third condition should start with a ISNULL check again before you compare your values. Like the following:

!ISNULL(Source.Id) && !ISNULL(Destination.Id) && Source.Id == Destination.Id

You need to handle every column that can be NULL in your condition. Since you are comparing Id's, another option would be:

(ISNULL(Source.Id) ? 0 : Source.Id) == (ISNULL(Destination.Id) ? 0 : Destination.Id)

If comparing strings, you can replace the zeroes with blank spaces.