dbTalk Databases Forums  

Calling Global Variable in DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Calling Global Variable in DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Nitin
 
Posts: n/a

Default Calling Global Variable in DTS - 06-03-2008 , 02:06 PM






I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Reply With Quote
  #2  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM






Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #3  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #4  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #5  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #6  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #7  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #8  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
  #9  
Old   
Ed Enstrom
 
Posts: n/a

Default Re: Calling Global Variable in DTS - 06-03-2008 , 06:22 PM



Nitin wrote:
Quote:
I have 5 folders each having 2-3 text files.
I have two DTS(SQL 2000) packages one which is having around 12 tasks which
is getting processed based on the records in '.txt' file, now what i need to
do is put this entire first package in a loop which will get the name of the
file from my second package which is saving the file name in a global
variable.



This is the activeXScript of my second package which is passing the name of
the text file to a global variable -

For Each objsubfold in foldSubfolders
for each fil in objsubfold.Files
DTSGlobalVariables("gv_FileFullName").Value = fil.Name
Next
Next


help needed asap



Nitin


Here's how I do it. (This is on SQL Server 2000). I create a function named ExecuteDTS in the outer package that
executes the inner package. The critical piece in making this work is creating the DTS.Package2 object in the function.
I equate the values from the DTS.GlobalVariables in the outer package to those in the function. In the sample below,
I select mail addresses from a view and loop through the record set in the outer package and call an inner package that
sends the mail. In this case, both packages reside on the server.



HTH

Ed

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************

Function Main()

set oCnn=CREATEOBJECT("ADODB.Connection")
set rs=CreateOBJECT("ADODB.Recordset")

strConn = "Provider=MSDASQL;Driver={SQLServer};Server=myserv er;Database=mydb;UID=myusername;PWD=mypassword"

oCnn.Open strConn

If oCnn.State = 1 Then
strSQl = "select distinct Email from mytable"


rs.Open strSQl, oCnn

If Not rs.EOF Then
rs.MoveFirst

While Not rs.EOF

DTSGlobalVariables("email").Value=rs("Email")
DTSGlobalVariables("subject").Value = "Items awaiting approval"

call ExecuteDTS("myserver","myusername", "mypassword","My DTS package name")

rs.MoveNext
Wend

End If
End If

Main = DTSTaskExecResult_Success
End Function


Function ExecuteDTS(servername,username,password,PackageNam e) 'Run the package

Dim objPackage

Set objPackage=createobject("DTS.Package2")

objPackage.LoadFromSQLServer servername,username,password,CPPDEFAULT,CPPDEFAULT ,CPPDEFAULT,CPPDEFAULT,PackageName

objPackage.GlobalVariables("email").Value = DTSGlobalVariables("email").Value
objPackage.GlobalVariables("subject").Value = DTSGlobalVariables("subject").Value

'Run the package and release references.

objPackage.execute

End Function



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.