Groups | Blog | Home
all groups > sql server dts > june 2004 >

sql server dts : Error setting global variable in DTS ExecuteSQL


ED P
6/30/2004 11:26:10 AM
I'm relatively new to DTS and am having what seems like a
very basic problem. I have simplified what I am trying
to do down to the following:

I create a global variable called gvRosterID as an int
with a default value of 10. Then I create a connection
and then and an associated ExecuteSQL Task with two lines
of SQL:
insert into egprosters values(1)
SELECT 99 as RosterID

I then set the Output Parameter RosterID to the global
variable gvRosterID and save the package.

Now I execute the package. A single row with a single
field value of 1 gets inserted into egprosters. But the
Global Variable is still 10.

Here's the odd thing. When I comment out the first line
(the insert), the global variable DOES get set to 99.
Or, when I move the insert statement to after the select,
the insert still occurs and the global variable does get
set to 99. Or, if I put this all inside a stored proc
and call the proc from the Execute SQL task, the behavior
is exactly the same - if the insert is before the select
inside the stored proc, the global variable does not get
set, otherwise it does.

I have tried checking and unchecking transactions in the
package and the stored proc, tried changing variable and
parameter names, etc. Doing an update or delete instead
of the insert causes the same problem. What I am
actually trying to do is slightly different than the
above, but this is the simplest example of the error.
What I am trying to do is do an insert (subject to a few
SQL checks), return the identity value of the inserted
row, and pass that value to the next task, which is a
Transform Data task.

Any thoughts would be welcome!

Allan Mitchell
7/1/2004 8:18:35 AM
What happens if you issue

SET NOCOUNT ON

as the first line in the batch?

Why not split the statements in the ExecuteSQL task into > 1 Task?

--

Allan Mitchell MCSE,MCDBA, (Microsoft SQL Server MVP)
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]

anonymous NO[at]SPAM discussions.microsoft.com
7/1/2004 10:20:44 AM
Thank you for the response. SET NOCOUNT ON did it. We
had actually tried that before, but with all the things
we tested, we must have had something else wrong when we
were testing that

Thanks again!

Ed P

[quoted text, click to view]
AddThis Social Bookmark Button