Free Newsletters:
DatabaseDaily  
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL Sybase PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner

internet.commerce
Be a Commerce Partner


















Mariposa Bot Shipped With Vodafone Smartphone

IT Job Market Heating Up: Report

Bing Makes Strides But Momentum Stalls

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2







C++ Developer - Fixed Income (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

December 28, 1999

Use Global Variables in Execute SQL Tasks (GVCustomTask)

By Darren Green

Thank you to those people who pointed out some bugs in the first release and sorry to anyone who encountered problems.

This DTS custom task allow you to use package global variables in Execute SQL Tasks.

It works by reading the global variables and converting them into T-SQL. It then examines all tasks in the package to find any Execute SQL Tasks. If found the global variable SQL is added to the front of the existing SQL.


Example

The following Global Variables will be used -
Sample global variables screen shot

The first section of SQL is added by the custom task, the second is a simple query that utilises the new variables -
/*GlobalVariableToSQL*/  DECLARE @FileName varchar(23)
/*GlobalVariableToSQL*/  SET @FileName = '\\Server\Share\File.txt'
/*GlobalVariableToSQL*/  DECLARE @StartDate datetime
/*GlobalVariableToSQL*/  SET @StartDate = '01/11/1999'
/*GlobalVariableToSQL*/  DECLARE @EndDate datetime
/*GlobalVariableToSQL*/  SET @EndDate = '30/11/1999'
/* This section is not altered in anyway by the task */
DELETE FROM tbRecords
WHERE RecordDate BETWEEN @StartDate AND @EndDate


Installation

  • Download and extract the archive to a suitable location (SQL 6.X or SQL 7.X version).
  • From within the DTS Designer select Register Custom Task from the Tasks menu
  • Supply a suitable description such as GlobalVariableToSQL Task
  • Supply the Task location (Find GVCustomTask.dll in the extraction directory)
  • Supply the Icon location (Find GVCustomTask.ico in the extraction directory)
  • Click OK and you are ready to go.

A more complete step by step guide is available here


Usage Notes

When designing the package, ensure that GVCustomTask is executed prior to any Execute SQL Tasks, using suitable workflow constraints.

The SQL variables will be declared with the same name as the global variable, and will not change.

Do not alter any lines prefixed with /*GlobalVariableToSQL*/ . Each time the package is run, the SQL is examined for the presence of this string, and if found the line is removed. The new global variable SQL is then added, preventing duplicate declarations in the SQL.

Only the following global variable types are supported at present - String, Int, Integer, Integer (Small), Currency, Date, Boolean, Decimal.
All other types will be placed in the SQL but commented out with a warning.

MS SQL Server 7 Service Pack 1 is required for this Custom Task. Without SP1 you will encounter automation errors when executing packages from the DTS designer. (See SQL Links).

There are now two versions of the CustomTask (GVCustomTask6.zip: v1.1.0 and GVCustomTask7.zip: v1.0.2). The new version will use SET instead of SELECT when defining the variables in SQL to enable compatibility with SQL 6.X servers.


Download

Please note that this program is provided without any warranty or assurances of any kind. Use it at your own risk. Commercial distribution or distribution for profit in any form is strictly forbidden without prior permission from the author.

Any
comments would be greatly appreciated.
Download GVCustomTask7 (~10K) or GVCustomTask6 (~10K).

Version History

Version 1.1.0 (28/12/1999) - Changed SQL parsing to use SET instead of SELECT for SQL 6.x compatibility. No other changes from v1.0.2.

Version 1.0.2 (06/11/1999) - Fixed SQL parsing which caused loss of first line. Fixed task properties which caused MMC to crash when task deleted.

Version 0.6.3 (31/10/1999) - First Public Release Version



Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives








Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
Help with Getting Started jozepeter 1 March 15th, 11:03 AM
sql maintenance plan fails database missing tbrownch 5 March 12th, 08:48 AM
Inner and outer select mussab 2 March 10th, 04:16 AM
SQL server 2008 in windows 7 pro problem theresatan 2 March 6th, 08:35 PM









The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers