dbTalk Databases Forums  

Accessing a global variable in a SQL Task in a DTS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Accessing a global variable in a SQL Task in a DTS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Eddie
 
Posts: n/a

Default Accessing a global variable in a SQL Task in a DTS - 03-06-2006 , 07:53 AM






Hello,

I'm trying to use a global variable in a simple SQL statement in a DTS.
I created a global variable (type integer) at the package level. I
know I can access it in an ActiveX script
(DTSGlobalVariables("myGlobalVariable").Value), but that syntax doesn't
work in the SQL statement.

My SQL is basically this:

SELECT myGlobalVariable = COUNT(*)
FROM myTable

Your consideration is much appreciated.

Eddie


Reply With Quote
  #2  
Old   
tbradshaw via SQLMonster.com
 
Posts: n/a

Default Re: Accessing a global variable in a SQL Task in a DTS - 03-06-2006 , 10:13 AM






Eddie,

You may want to check this out, especially the paragraph before 'Input &
Output Parameters':

http://www.sqldts.com/default.aspx?234

Lots of other goodies here too. Let us know how you make out.

- Tom

Thomas Bradshaw
MyWebGrocer.com
Data Integration Services

--
Message posted via http://www.sqlmonster.com

Reply With Quote
  #3  
Old   
Eddie
 
Posts: n/a

Default Re: Accessing a global variable in a SQL Task in a DTS - 03-06-2006 , 01:33 PM



Tom,

Thank you for pointing me in that direction. I set up a tiny stored
procedure to run my SQL with an output parameter for my rowcount. I
set up the DTS to call the stored procedure (like at the website you
suggested) and store the returned value and output parameter as a query
result. If I run the SQL from the DTS in Query Analyzer, I get the
correct value in the output parameter. But the value of the global
variable is not changing when I run the DTS, and I did map the global
variable to the output parameter, so I am at a loss as to why I can't
get the global variable to change value.

Still tryin'....


Reply With Quote
  #4  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Accessing a global variable in a SQL Task in a DTS - 03-06-2006 , 02:56 PM



Hello Eddie,

How do you know the value is not changing?

The code is the exact same between QA and DTS?


Allan Mitchell
www.SQLDTS.com
www.SQLIS.com
www.Konesans.com

Quote:
Tom,

Thank you for pointing me in that direction. I set up a tiny stored
procedure to run my SQL with an output parameter for my rowcount. I
set up the DTS to call the stored procedure (like at the website you
suggested) and store the returned value and output parameter as a
query result. If I run the SQL from the DTS in Query Analyzer, I get
the correct value in the output parameter. But the value of the
global variable is not changing when I run the DTS, and I did map the
global variable to the output parameter, so I am at a loss as to why I
can't get the global variable to change value.

Still tryin'....




Reply With Quote
  #5  
Old   
Eddie
 
Posts: n/a

Default Re: Accessing a global variable in a SQL Task in a DTS - 03-07-2006 , 06:04 AM



Hi Allan,

I've gone over it a few times, as has my manager, and we see no
differences between my code and the sample code at SQLDTS.

After I execute the particular step in the DTS which should change the
value of the global variable, I check it's value by looking at the
Properties of the Package. And it's not changing. The value in the
parameter is correct, but the global variable remains unchanged.
Whatever value I initially set the global variable is it's value
throughout my DTS.

We've searched online and found other instances where people have said
this same code does not work, but we haven't found an alternative
solution yet.

Eddie


Reply With Quote
  #6  
Old   
tbradshaw via SQLMonster.com
 
Posts: n/a

Default Re: Accessing a global variable in a SQL Task in a DTS - 03-07-2006 , 12:43 PM



Hello Eddie,

Have you checked the case-sensitivity of your Global Variable names so they
all match exactly? For example, if you have a global variable "MaxProductID",
but have an ActiveX task with a lower-case "m", such as:

MsgBox DTSGlobalVariables("maxProductID").Value

You won't see your global variable, but instead create a new one.
Not sure if this matters, but just a thought.

- Tom

--
Message posted via SQLMonster.com
http://www.sqlmonster.com/Uwe/Forums...r-dts/200603/1

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.