first_page the funky knowledge base
personal notes from way, _way_ back and maybe today

DTS ActiveX Script Task: Assigning SQL Statements to Execute SQL Tasks Based on Global Variables

'Based on Global Variables and SQL statements in DTS by Darren Green 'http://www.sqldts.com/Default.aspx?205,2 Option Explicit

Function Main() Dim objDtsPack,vSQL

' Get reference to the Exec SQL Task
Set objDtsPack = DTSGlobalVariables.Parent

'Delete Quiz Participant tasks:
vSQL = "DELETE FROM ParticipantQuiz WHERE pID IN(" _
    & "SELECT pID FROM Participant WHERE domainUserName = '" _
    & DTSGlobalVariables("ImportGroup").Value _
    & "')"

Call SetDtsSql(objDtsPack,"DTSTask_DTSExecuteSQLTask_3",vSQL)
Call SetDtsSql(objDtsPack,"DTSTask_DTSExecuteSQLTask_6",vSQL)

' Clean Up
Set objDtsPack = Nothing

Main = DTSTaskExecResult_Success

End Function

Sub SetDtsSql(objDtsPack,vTaskName,vSQL) Dim objExecSqlTask Set objExecSqlTask = objDtsPack.Tasks(CStr(vTaskName)).CustomTask

' Assign SQL Statement to Exec SQL Task
objExecSqlTask.SQLStatement = vSQL

' Clean Up
Set objExecSqlTask = Nothing

End Sub

mod date: 2005-09-15T22:22:30.000Z