DTS -- "If/Then" Statement

  • How can I modify the following DTS ActiveX

    Script so it ONLY emails me if OIW_DOLLAR > 0 ?

    ---------------------------------------------------

    Function Main()

    Dim iMsg

    set iMsg = CreateObject("CDO.Message")

    Dim objMail

    Set objMail = CreateObject("CDO.Message")

    objMail.From = "test@test.com"

    objMail.To ="test@test.com"

    objMail.Subject="your subject here"

    objMail.TextBody = DTSGlobalVariables("OIW_DOLLAR").value

    objMail.Send

    Set objMail = nothing

    Main = DTSTaskExecResult_Success

    End Function

    ---------------------------------------------------

     

  • You have a couple fo ways to do this.

    You can retrieve the value of OIW_DOLLAR into a global variable and then use if, then, else, end if on the value of the variable, just as you would in a normal vb script.

    I.E

    Function Main()

    If gvOIWDollar > 0 Then

      do logic

    Else

      do something else

    End if

    Main = DTSTaskExecResult_Success

    End Function

    Another way is to set the task to false at the end of the code. See this snippet from http://www.sqldts.com/default.aspx?214,1

    If you need to find out more about global variables, there are some good examples to follow on sqldts.com. Always a good place to start.


    ------------------------------
    The Users are always right - when I'm not wrong!

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

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