dbTalk Databases Forums  

Using Global variables

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


Discuss Using Global variables in the microsoft.public.sqlserver.dts forum.



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

Default Using Global variables - 01-06-2004 , 02:36 AM






Hello.
I have Execute SQL Task with SELECT * FROM ORDERS WHERE OrderID=10248 and I
created two variables
as f=10248 (int) and r=10249(int)

Then I wrote on Active Script Task
MsgBox "The order ID is " & DTSGlobalVariables("f").value
Main = DTSTaskExecResult_Success

Now I have couple questions
How do I execute SELECT statement within Execute SQL Task without putting
the OrderID=10248 ( I thought we can put '?' but still it does not work) ?

Even though when I execute my package with orderid= 10248 then the r
variable also get 10248 value , why?




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

Default Re: Using Global variables - 01-06-2004 , 02:56 AM






If you are using SQL Server 2000 you can use ?
When you execute a package externally and change a Global Variable it will
still be the same value as at runtime when you open it back up again not the
value you used. The value the package uses though will be what you passed
in.

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote

Quote:
Hello.
I have Execute SQL Task with SELECT * FROM ORDERS WHERE OrderID=10248 and
I
created two variables
as f=10248 (int) and r=10249(int)

Then I wrote on Active Script Task
MsgBox "The order ID is " & DTSGlobalVariables("f").value
Main = DTSTaskExecResult_Success

Now I have couple questions
How do I execute SELECT statement within Execute SQL Task without putting
the OrderID=10248 ( I thought we can put '?' but still it does not work) ?

Even though when I execute my package with orderid= 10248 then the r
variable also get 10248 value , why?






Reply With Quote
  #3  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Using Global variables - 01-06-2004 , 03:17 AM



Allan
Thanks for your answer.
Yes I am using SQL Server 2000(SP3)
I am not executing package externally but only within EM .

When I try SELECT * FROM ORDERS WHERE OrderID=? then I 've got the error
"No value given for one or more required parameters"

At your wonderful site written that I can alter Execute SQL Task but It
looks like Active Script Task syntax and Do I need to install GVCustomTask ?

Can you give me an example ? If you have a time I would send you DTS file.



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
If you are using SQL Server 2000 you can use ?
When you execute a package externally and change a Global Variable it will
still be the same value as at runtime when you open it back up again not
the
value you used. The value the package uses though will be what you passed
in.

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:OmPZifC1DHA.2160 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hello.
I have Execute SQL Task with SELECT * FROM ORDERS WHERE OrderID=10248
and
I
created two variables
as f=10248 (int) and r=10249(int)

Then I wrote on Active Script Task
MsgBox "The order ID is " & DTSGlobalVariables("f").value
Main = DTSTaskExecResult_Success

Now I have couple questions
How do I execute SELECT statement within Execute SQL Task without
putting
the OrderID=10248 ( I thought we can put '?' but still it does not work)
?

Even though when I execute my package with orderid= 10248 then the r
variable also get 10248 value , why?








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

Default Re: Using Global variables - 01-06-2004 , 03:44 AM



Let's take Pubs:authors

I have a Global Variable of String gv_Authors_id

My ExecuteSQL string is

select au_lname from authors where
au_id = ?

I hit parameters
I assign my Global Variable to an Input parameter

What is the connection data source for the ExecuteSQL task ?



--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote

Quote:
Allan
Thanks for your answer.
Yes I am using SQL Server 2000(SP3)
I am not executing package externally but only within EM .

When I try SELECT * FROM ORDERS WHERE OrderID=? then I 've got the error
"No value given for one or more required parameters"

At your wonderful site written that I can alter Execute SQL Task but It
looks like Active Script Task syntax and Do I need to install GVCustomTask
?

Can you give me an example ? If you have a time I would send you DTS
file.



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:#BjOdqC1DHA.3496 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
If you are using SQL Server 2000 you can use ?
When you execute a package externally and change a Global Variable it
will
still be the same value as at runtime when you open it back up again not
the
value you used. The value the package uses though will be what you
passed
in.

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:OmPZifC1DHA.2160 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hello.
I have Execute SQL Task with SELECT * FROM ORDERS WHERE OrderID=10248
and
I
created two variables
as f=10248 (int) and r=10249(int)

Then I wrote on Active Script Task
MsgBox "The order ID is " & DTSGlobalVariables("f").value
Main = DTSTaskExecResult_Success

Now I have couple questions
How do I execute SELECT statement within Execute SQL Task without
putting
the OrderID=10248 ( I thought we can put '?' but still it does not
work)
?

Even though when I execute my package with orderid= 10248 then the r
variable also get 10248 value , why?










Reply With Quote
  #5  
Old   
Uri Dimant
 
Posts: n/a

Default Re: Using Global variables - 01-06-2004 , 03:54 AM



Thanks, Allan
It works like a charm.

"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote

Quote:
Let's take Pubs:authors

I have a Global Variable of String gv_Authors_id

My ExecuteSQL string is

select au_lname from authors where
au_id = ?

I hit parameters
I assign my Global Variable to an Input parameter

What is the connection data source for the ExecuteSQL task ?



--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:%23AMicrosoftM2C1DHA.1736 (AT) TK2MSFTNGP09 (DOT) phx.gbl...
Allan
Thanks for your answer.
Yes I am using SQL Server 2000(SP3)
I am not executing package externally but only within EM .

When I try SELECT * FROM ORDERS WHERE OrderID=? then I 've got the
error
"No value given for one or more required parameters"

At your wonderful site written that I can alter Execute SQL Task but It
looks like Active Script Task syntax and Do I need to install
GVCustomTask
?

Can you give me an example ? If you have a time I would send you DTS
file.



"Allan Mitchell" <allan (AT) no-spam (DOT) sqldts.com> wrote in message
news:#BjOdqC1DHA.3496 (AT) TK2MSFTNGP11 (DOT) phx.gbl...
If you are using SQL Server 2000 you can use ?
When you execute a package externally and change a Global Variable it
will
still be the same value as at runtime when you open it back up again
not
the
value you used. The value the package uses though will be what you
passed
in.

Global Variables and SQL statements in DTS
(http://www.sqldts.com/default.aspx?205)

--

----------------------------
Allan Mitchell (Microsoft SQL Server MVP)
MCSE,MCDBA
www.SQLDTS.com
I support PASS - the definitive, global community
for SQL Server professionals - http://www.sqlpass.org



"Uri Dimant" <urid (AT) iscar (DOT) co.il> wrote in message
news:OmPZifC1DHA.2160 (AT) TK2MSFTNGP12 (DOT) phx.gbl...
Hello.
I have Execute SQL Task with SELECT * FROM ORDERS WHERE
OrderID=10248
and
I
created two variables
as f=10248 (int) and r=10249(int)

Then I wrote on Active Script Task
MsgBox "The order ID is " & DTSGlobalVariables("f").value
Main = DTSTaskExecResult_Success

Now I have couple questions
How do I execute SELECT statement within Execute SQL Task without
putting
the OrderID=10248 ( I thought we can put '?' but still it does not
work)
?

Even though when I execute my package with orderid= 10248 then the
r
variable also get 10248 value , why?












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.