DTS Looping

  • I need to check the results of a SQL statement and if they are false I need to wait 5 minutes and then check it again until it is true at which point I send notification of completion. I'm looking at this as needing to set up a loop with a wait and SQL statement steps inside the loop. I am having trouble figuring out how to set up the loop. Anyone have any suggestions - they would be greatly appreciated.

  • Thanks for the link - I did run across this, but was looking for something much simpler - I just want to check the status of a global variable and if it is false go back and wait and exectue a sql statement again otherwise exectue the next step. I may have actually found something in this:

    Function Main()

       Dim oPkg

          DTSGlobalVariables("counter").Value = _

          DTSGlobalVariables("counter").Value + 1

          If DTSGlobalVariables("counter").Value < 5 THEN

             Msgbox DTSGlobalVariables("counter").Value

             Set oPkg = DTSGlobalVariables.Parent

             'Set previous step status to waiting.

             oPkg.Steps("DTSStep_DTSActiveScriptTask_1").ExecutionStatus = _

                DTSStepExecStat_Waiting

             'Do not execute task 2, step 1 will restart.

             Main = DTSStepScriptResult_DontExecuteTask

          Else

             'Execute task 2, do not restart step 1.

             Main = DTSStepScriptResult_ExecuteTask

          END IF

    End Function

  • Is there a reason a workflow from the SQL Task to an ActiveXTask will not work? That would be the simplest solution.

  • You could do it all in a SQL task:

    WHILE NOT (...) WAITFOR DELAY '00:05:00'

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

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