Search code examples
sql-serverssisetlssis-2012

Microsoft SSIS Conditional Split is not working correctly


I need to do the conditional split of data based on the source file record count and process data count if both count match then only i need to perform the insert into DB table but some where my conditional split is failing please find the screen shot and let me know what is wrong

enter image description here enter image description here


Solution

  • I don't think that you can achieve that within one data flow task, since variables values are committed at the end of Data flow Task execution.

    In your case it will always shows that the row counts are equals since they are both equals to zero.

    You have to create 2 data flow task and one script task:

    1. First Data Flow Task to get the Original Count and Extracted count and to store them within two variables.
    2. Second Data Flow Task is to import Data into an OLE DB Destination (just a Flat File Source and an OLE DB Destination)
    3. The Script Task is to notify user that the data is Invalid

    Add a precedence constraint between the First DFT and the second one. In addition, add a precedence constraint between the first DFT and the Script Task

    On each precedence constraint add an expression:

    Between Data Flow Tasks

    @[User:OriginalRowCount] == @[User::ExtractedRowCount]
    

    Between DFT and Script Task

    @[User:OriginalRowCount] != @[User::ExtractedRowCount]