Checking if row exist before import

  • I want to import data using DTS.

    Can I make a validation to check if data already exist for each and every record before importing?

    by doing this I will not get error "Duplicate primary key"

  • Yes look at the Lookups tab depending on the location you are talking about. You can create a lookup query (select 1 from table where pk = ?) pass the data in and get back a 1 so yu know the condition of it's existence is true.

    You will however have to use an ActiveX transformaton for this to work. And it you want to be able to Update the data instead of insert you will want to use a Data Driven Qeuy Task.

    In ActiveX trans this is what you do to call the Lookup

    if DTSLookups("LookupName").Execute(DTSSource("SourceValueToCheckFor")) = 1Then

      Main = DTSTransformStat_SkipRow ' Skips this row and continues execution

     Else

    'This is where your standard transfomation will take place

    Main = DTSTransformstat_InsertQuery

    End If

  • Hi, It work like a Champ.

    Thanks.

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

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