Is there a way to use Global variables in the 'Execute SQL task' in a DTS package? if no is there a way to?Yes, depends on what version of SQL Server you have. In SQL Server 2000, you can use question marks as place holders for parameters, then assign the global variables to the question marks using the parameters button in the execute sql screen.
If you are using sql7 then I found this to work. Add an active x script to the package that creates and sets the sql command of the execute sql task. when you create the sql command in the vb script, use the variables you want. Here is the syntax of the active x script.
Steve
'*********************************
' Visual Basic ActiveX Script
'*********************************
Function Main()
Dim oPkg, oExecSQL, sSQLStatement
sSQLStatement = "EXEC stpr_createtable " & DTSGlobalVariables("tableName").Value
Set oPkg = DTSGlobalVariables.Parent
Set oExecSQL = oPkg.Tasks("DTSTask_DTSExecuteSQLTask_1").CustomTask
oExecSQL.SQLStatement = sSQLStatement
Set oExecSQL = Nothing
Set oPkg = Nothing
Main = DTSTaskExecResult_Success
End Function
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment