Bandwidth Monitor
SQLDTS.comSQLIS.comSQLIS Wiki
Introduction to Expressions on Workflow
By Allan Mitchell
Version 2005
Level Intermediate
Page 1 | Page 2 | Page 3

The first thing we need to do in our package is create a new variable so let's go there and create our variable and name it DayOfWeek

SetUpVariable

This variable will be used later in our expressions. We now need a way to set the value of the variable dynamically and for that we are going to use the Script task. Drag one onto designer from the toolbox and double click on the task. Select Script from the left hand side and then click the Design Script button on the right hand side. There will be a section in there that tells you where to write your code. Here is the code we use.

Public Sub Main()
		


        Dim vs As Variables

        'We need to lock the variables so we can read it without anything else changing it
        Dts.VariableDispenser.LockOneForWrite("DayOfWeek", vs)

        'Assign it a value
        vs.Item("DayOfWeek").Value = System.DateTime.Now.DayOfWeek.ToString

        'remember to unlock the variable now
        vs.Unlock()

		
		Dts.TaskResult = Dts.Results.Success
End Sub

Page 1 | Page 2 | Page 3