how to use if condition in oledb source(SSIS)

  • Dear friends

    I have to download one table if the given condition is true .

    else i have to download another table..

    plz suggest me..

  • Number of ways you could do this, if I understand you correctly.

    One way might be to create the two separate data flows and use a precedence constraint to determine which of the two to run depending on the value of a specific condition. This would be necessary if your tables contain very different data structures etc...

    Another way, if the recordsets will require identical treatment and are very similar, would be to use one connection, but pass the query as a variable that in turn contains another variable being the table name to select the data from ... e.g.

    In the OLEDB connection manager, choose data access mode to be "SQL Command from variable". Then you specify a string variable you need to create, something like this

    "select * from " + @Variable1

    And @Variable1 is another string variable that has already been populated and will be one of your 2 table names depending on some constraint.

    Kind Regards, Will

  • from the 1st solution you will need to FORCE an Error to divert the data flows if you don't 'want' to go a specific route in the data flow process in a SSIS packege ... :unsure: am i correct in saying this ?

    In my situation I'm checking if data already exists in a table and if it doesn't I want to use the insert SQL task i created and if the record exists I want to NOT insert but continue to end the package normally ...

    MCITP: Database Administrator 2005
    MCTS SQL Server 2008
    MCP SQL 2012/2014
    MCSA SQL Server 2012/2014
    MCSE Data Management and Analytics

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply