SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Using DTS Global Variables

By Brian Knight, 2001/05/16

Total article views: 13766 | Views in the last 30 days: 84
Global variables are a little known solution in Data Transformation Services (DTS). Often packages become "stale", where you must develop a package for each client. Using global variables, you can create one DTS solution for all clients and substitute any dynamic properties with global variables. This article will cover the basics on how to use them in SQL Server 7.0. In SQL Server 2000, the role of global variables has been expanded. Global variables offer you the following options:
  • Making a DTS package dynamic
  • Passing variables to other packages
  • Creating modular DTS packages
  • Passing information from task to task

You can edit a package's global variables by clicking Properties under the Package menu in DTS Designer. In this example, we will create a global variable called gvclientmessage and give it the string value of "Get lost world". We will then create a small ActiveX script to show the variable in a dialog box. You can start by adding the variable:

You can call the global variable by using the DTSGlobalVariables object. A dialog box can be raised with the global variable by typing the following:

Dialog=MsgBox(DTSGlobalVariables("gvclientmessage").value)

DTS global variables by default are case sensitive. Be careful to not mistype a single variable name or nothing will happen when you execute the package. Your ActiveX script should now look like this:

Now, execute the package. You can execute the package under the Package menu. You should see the following:

Although this example is simple, it gives you the basics to calling gloabl variables DTS global variables can also help you in many other ways, which we will explore next week. Next week we will delve into a more advanced script to dynamically read a file and change the connection properties.

By Brian Knight, 2001/05/16

Total article views: 13766 | Views in the last 30 days: 84
Your response
 
 
Related Articles
FORUM

SSIS global variables and package variables

How to create variables to be used in multiple packages.

FORUM

Global variable

Assign value to global variable

FORUM

Global Variables

Assign MAX(date) to Globale variables

FORUM

How & where do you write to a Variable that has scope the entire Package?

Package Variable similar to Global Variable in DTS

Tags
dts    
sql server 7, 2000    
 
Contribute

Free registration required...

To read the rest of this article, and access thousands of other articles, we ask you to register on the site and subscribe to our newsletters.

Login (existing users)

Login

Email:   Password:   Remember me: Forgotten your password?

Register (new users)

Register

Email:   Password:
Confirm:

Subscribing to our newsletters gets you:

  • ALL of our content (thousands of articles, scripts, and forum postings)
  • A daily newsletter (example)
  • A weekly news round up (example)
  • The opportunity to ask and answer questions in our forums
  • A daily Question of the Day to test and help you increase your knowledge of SQL Server.

Steve Jones
Editor, SQLServerCentral.com