'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