all groups > sql server dts > january 2004 >
You're in the

sql server dts

group:

Global Variables in DTS


Global Variables in DTS Terry Hannon
1/28/2004 2:32:10 PM
sql server dts: Hi Everyone,

I am pretty new to DTS and am trying to setup a global variable.

Basically I want to do the following:

1) Select Max(date) from table into global variable
2) Use global variable in the SQL portion of my transform data task to only
select rows that have a date greater than my global variable.

This does not seem hard, but when I look into the Books online it tells me
to use a ExecuteSQLTask2 object, but I cannot seem to find it anywhere in
the design window. I am running SQL Server 2000, and cannot figure out how
to use a ExecuteSQLTask2 object.

Any help would be very much appreciated.

Thanks
Terry Hannon

Re: Global Variables in DTS Terry Hannon
1/28/2004 3:37:12 PM
Thanks Allan,

I finally got it to work.

Terry Hannon

[quoted text, click to view]

Re: Global Variables in DTS Allan Mitchell
1/28/2004 10:54:43 PM
Ahhhh

I presume that because you are using > MAX that the MAX is coming from a
different table? Different server?

OK

Non DTS specific would be

SELECT ..FROM TABLE WHERE DateCol > (SELECT MAX(DateCol) FROM OtherTable)


DTS Would look like

How to Use Lookups in DTS
(http://www.sqldts.com/default.aspx?277,1)


You could assign the value as an Output Global Variable in one ExecuteSQL
task and assign it in the datapump

SELECT MAX(DateCol) FROM Table


Then

SELECT .. FROM TABLE WHERE DateCol > ?

you then map the parameter to the GV





--
--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
www.allisonmitchell.com - Expert SQL Server Consultancy.
www.SQLDTS.com - The site for all your DTS needs.
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org


[quoted text, click to view]

AddThis Social Bookmark Button