Groups | Blog | Home
all groups > sql server (alternate) > december 2004 >

sql server (alternate) : Q: DTS and global variables


B
12/29/2004 7:32:39 AM
Using SQL2000, I have a DTS that takes data from MySQL to sqlserver, the
catch is I want to specify a specific range of dates.

How to use a global variable? At the moment I manually changes the dates and
jobs run on a daily basis.

sample sql statement from Mysql connection:
select *
from Table1
where date between '1/1/2004' and '6/30/2004'

CHANGE TO:
select *
from Table1
where date between @fromdate and @todate

TIA
Bob

David Portas
12/29/2004 10:22:26 PM
Within a package you can assign global variables in any of several ways: In
an ActiveX Script task, a Dynamic Properties task or as the result of an
Execute SQL task for example. If you are invoking the package from code then
you can create and assign global variables in the the GlobalVariables
collection of the Package object. If you are running the package with the
DTSRUN utility then use the /A switch to assign global variables.

To use a global variable in a query you just need to put ? as a placeholder
in the properties dialog of the Execute SQL task. Then click on Parameters
and specify which global vars are assigned to which parameter in their
respective order.

--
David Portas
SQL Server MVP
--

AddThis Social Bookmark Button