SQL Server Central is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
Search:  
 
 

Using DTS Global Variables

By Brian Knight, 2001/05/16

Total article views: 12521 | Views in the last 30 days: 116
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: 12521 | Views in the last 30 days: 116
Your response
 
 
Related tags

DTS    
SQL Server 7, 2000    
 
Related content

Locking Down DTS

By Brian Knight | Category: DTS
| 8,005 reads

DTS Basics

By Brian Knight | Category: DTS
| 10,159 reads
Like this? Try these...

DTS Basics

By Brian Knight | Category: DTS
| 10,159 reads
Already registered?  

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.

Register

E-mail address:
Password:
Password (confirm):

  

Subscriptions

We ask you to register on the site and subscribe to our newsletters. 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.

We ask that you give the newsletter a try for a week. Over 200,000 SQL Server Professionals a day find it entertaining and useful. If not, you are welcome to unsubscribe at anytime.

Steve Jones
Editor, SQLServerCentral.com