Need to schedule a single task in an SSIS package

  • Hi All,

    I need your help with this problem.

    Currently we have an SSIS package that runs nightly using a batch file.

    Now we want to add one more task to execute a stored procedure. But this new task should run only once in a week while the entire package runs daily.

    So My questions is : Can we do this? If yes, how can we do?

    Your help is greatly appreciated. Thank you.

    Regards,

    Swathi.

  • Say for example you want to run the stored proc only on Wednesdays. One way would be to have a check in the package that checks the current day against Wednesday and only executes the proc if that is true. I'd personally do the check in a script task.

  • Hi Paul,

    Thanks for the reply.

    yes, that makes sense. Can you please help me with that code in the Script task?

    Thanks very much in advance.

    Regards,

    Swathi.

  • Create a Boolean variable IsWeds.

    Create a script task containing some code like this.

    Public Sub Main()

    Try

    Dts.Variables("IsWeds").Value = False

    If Now.DayOfWeek = 3 Then

    Dts.Variables("IsWeds").Value = True

    End If

    Dts.TaskResult = Dts.Results.Success

    Catch ex As Exception

    Dts.TaskResult = Dts.Results.Failure

    End Try

    End Sub

    Make IsWeds a ReadWrite variable in this script.

    Then create suitable precedence constraints after the task which depend on the variable.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • You could even take it one step further and make the day of the week you wish to execute the task on configurable. So "Wednesday" would be stored in a variable itself (or even read from a table somewhere). You could then change this day by simply changing the variable from Wednesday to Monday for example.

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

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