dbTalk Databases Forums  

Global Package Variables in an Execute SQL Step as part of IF

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


Discuss Global Package Variables in an Execute SQL Step as part of IF in the microsoft.public.sqlserver.dts forum.



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

Default Global Package Variables in an Execute SQL Step as part of IF - 11-15-2005 , 10:42 AM






What I want is a way for an Execute SQL Step to get access to a package
global variable so that I can do decisions based on it and I cannot figure
out how. What I have is a global variable called "LogDebug". I need this to
be used in an Execute SQL Task in the following manner:

IF DTSGlobalVariables("ExecutionResult").Value <>0
BEGIN
INSERT INTO DebugLog() VALUES ()
END

How can I accomplish this? I have tried the following:

1)
DECLARE @DebugOn bit
SELECT @DebugOn = ?
IF @DebugOn <>0
BEGIN
INSERT INTO DebugLog() VALUES ()
END

2)
IF ? <>0
BEGIN
INSERT INTO DebugLog() VALUES ()
END

I thought that the ? was the way to indicate parameter usage but I must be
doing something wrong. Anyone have any ideas? I searched and only found
examples of using the "?" character as part of WHERE clauses. Not what I
need it to do.

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

Default Re: Global Package Variables in an Execute SQL Step as part of IF - 11-15-2005 , 02:16 PM






You can have a look to fo something like this

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

OR

If the ExecuteSQL statement is the last thing in the data flow then why
not check the value of the variable in an Active Script task and then
enable/Disable the ExecuteSQL task. The Active Script task will need to
come before the ExecuteSQL task in the workflow.

Allan

"Mike Sharpe" <MikeSharpe (AT) discussions (DOT) microsoft.com> wrote


Quote:
What I want is a way for an Execute SQL Step to get access to a package
global variable so that I can do decisions based on it and I cannot
figure
out how. What I have is a global variable called "LogDebug". I need
this to
be used in an Execute SQL Task in the following manner:

IF DTSGlobalVariables("ExecutionResult").Value <>0
BEGIN
INSERT INTO DebugLog() VALUES ()
END

How can I accomplish this? I have tried the following:

1)
DECLARE @DebugOn bit
SELECT @DebugOn = ?
IF @DebugOn <>0
BEGIN
INSERT INTO DebugLog() VALUES ()
END

2)
IF ? <>0
BEGIN
INSERT INTO DebugLog() VALUES ()
END

I thought that the ? was the way to indicate parameter usage but I must
be
doing something wrong. Anyone have any ideas? I searched and only
found
examples of using the "?" character as part of WHERE clauses. Not what
I
need it to do.


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

Default Re: Global Package Variables in an Execute SQL Step as part of IF - 11-15-2005 , 02:18 PM



Mike,

I think you need to use ActiveX Script task instead of Execute SQL task.
The ActiveX Script task will allow you to use global variables and SQL
statments. It is easy and poweful. Use ADODB.Connection objects.

Hope this info helps.


*** Sent via Developersdex http://www.developersdex.com ***

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.