Deleting rows before Insertion

  • Hi All,

    Can you please suggest me how to delete rows from a particular table before inserting rows into that using SSIS.

    Please reply fast.

    Thanks all.

  • Use SQL command on the first step(before inserting) of SSIS package, then insert into the table 🙂

  • Can u plz be more specific.

    Its not exactly deleting.

    I need to update the existing row, if the value for the same row comes from the source.

    Please tell me how to do it.

    Thanks.

  • What you need to do, is add a lookup transformation that will check against the destination table and use this to check whether the value exists already,

    If it does exist then you may need to send this data-flow to an update SQL command, and send all the new values to a database destination.

  • Can u please be more specific.

    I have used Look up transformation.

    After that, which transformation to use to find the value is already existing.

    As i am a beginner to SSIS, please explain me.

    Thanks.

    🙂

  • In the look-up transformation.

    select the destination table , and the columns tab join the input columns to the destination table based upon your primary key(s).

    Then add this primary key column from the destination table to the lookup column.

    Attach this look-up transformation to a conditional split, and have the criteria for the split as where you have a primary key from the look-up (as in the record exists)

    send the new ouput flow to a destination transformation.

    send the update output flow to a destination transformation that includes update statements.

  • please help me how to use conditional split. 🙂

  • conditional split is fairly easy, attach the input data flow from your look-up transformation.

    open up the properties of the split, in the condition box add the condition ISNULL(YourPKgoesHere). Give this output the name of NewRecord.

    do the same again but use a different condition NOT ISNULL(YourPKgoesHere), call this output

    UpdateRecord

    when you connect up the output of the slpit it will ask what output you want to use, send the NewRecord to the insert destination, send the UpdateRecord to your update destination.

    One thing i forgot to mention about the lookup is that you will need to change the error options to ignore error on lookup failure or else will not get the missing values

  • Hi,

    But I din't find any NOT IS NULL condition in Conditional split.

    Where it is?

    How to use it?

    Thanks for your replies and ur help. But, I din't come up with the solution.

    So, please help me.

    Thanks.

  • Search around this site and on google for "Slowly Changing Dimension". The topic you are asking about has been discussed a lot. I have posted a number of examples and depending on the size of your tables, a transformation component has been provided by MS for doing this.

    I would also suggest you visit www.sqlbi.com and take a look at the TableDifference component.

Viewing 10 posts - 1 through 9 (of 9 total)

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