How do I add an "IF THEN ELSE" statement in a DTS package?

  • I have created a DTS package that transfers data from a web SQL database to an application SQL database.  So far the data transfers correctly without any errors.  However the data coming from the web SQL has certain exceptions.  If certain fields are populated with certain data, a certain product from the application SQL db needs to be selected.  Is there a way to make exceptions in the data transfer?  Something similar to IF THEN ELSE?

    Thanks,

    Nikki

  • Nikki,

    If you go into the Transformations Tab and select "New" you can use the ActiveX transformation which will let you use VBScript to do the IF..Then..ELSE.

  • Thanks for the help. I did try that earlier, but when I executed the package I got an error, so naturally I clicked "ok" on the error message.  I began to troubleshoot my statment, but I was booted out of the DTS section and my database was "grayed" out.  It was the strangest thing.  I thought the script had corrupted the database.  I'll try it again, the script is pretty lengthy.  I've never used DTS before, I'm a Crystal Report writer at heart.

    Thanks again.

    Nikki

  • Nikki,

    Following is part of my code copied from ActiveX Transformation. You can modify it to your needs. Hope it helps you.

    '**********************************************************************

    '  Visual Basic Transformation Script

    '************************************************************************

    '  Copy each source column to the destination column

    Function Main()

    If IsNull( DTSSource("GROUP") ) = 0 Then

    DTSDestination("GroupID") =

    DTSLookups("Group").Execute(DTSSource("GROUP"))

    Else

    DTSDestination("GroupID") = 1

    End If

     Main = DTSTransformStat_OK

    End Function

  • Probably the best option is to keep your DTS import as a  simple Datapump and transfer the data into a seperate table. Then just use standard T-SQL to handle you exceptions when inserting into the productions tables.

     

    --------------------
    Colt 45 - the original point and click interface

Viewing 5 posts - 1 through 4 (of 4 total)

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