A step by step guide for the GVCustomTask written in response to a newsgroup posting:
Here is a step by step guide.
- Download and extract GVCustomTask.dll to a suitable location
- Open Enterprise Manager and create a New Package
- From the Task menu select Register Custom Task
- Supply a suitable description, and browse for the DLL & ICO files to
where you placed them in step 1
- Create a New global variable from the Package Properties dialog
- Add an Active Script Task, and place the relevant code to assign a
value as required to the global variable. (As per you code above)
- Add the GVCustomTask. Just click OK for the Custom Task Properties
- Add a SQL Server Connection
- Add an Execute SQL Task. Just put -- in the code for now
- Link the task with On Success workflow constraints:
Active Script -> GVCustomTask -> Execute SQL Task
- Run the package
- Open Execute SQL Task, and you will some new lines of code that
declares the global variable and sets it to the current value
- Now add your SQL code below that added by GVCustomTask. Do not alter
the GVCustomTask produced code These lines are prefixed with
- Now you are ready to go.
The reason for putting in the SQL code at stage 8, is that if you put
your full code in it will give a syntax error and not allow you to close
the box as the variables have not yet been declared. When you run the
Pkg, GVCustomTask reads the global variables and builds the SQL to
declare and set the variables. It then places this code at the top of
any existing code.
The point of the /*GlobalVariableToSQL*/ text before the declare and set
is so that next time you run the Pkg the GVCustomTask will remove any
lines prefixed with this and then add the new code it has built. This
prevents you getting duplicate declarations of variables. It also means
you are always using the current Global Variables.