dbTalk Databases Forums  

DTSGlobalVariable resetting to original value

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


Discuss DTSGlobalVariable resetting to original value in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
effervescent@hotmail.com
 
Posts: n/a

Default DTSGlobalVariable resetting to original value - 11-07-2004 , 03:14 AM






Hi,

This seems so simple, but I can't figure it out.
I'm trying to keep a 'seed' value in a global variable as an
integer value, essentially a count, to insert as a primary key into a
table. So i created an Integer global variable, set its value to 1. I
loop through some records, doing inserts, incrementing the global
variable. Say I insert 5 records in the first run. I would expect the
global variable to be 6, right? It's still 1. But the records all have
their correct ID's.. 1 - 5. I don't get it. Any ideas?

Thanks!


Reply With Quote
  #2  
Old   
Nigel Rivett
 
Posts: n/a

Default RE: DTSGlobalVariable resetting to original value - 11-07-2004 , 05:49 PM






The global variable value is contained in the saved package. You get this
initial value when you load the package then it is used when you run it. You
are then updating the value in memory but when you finish the run and load
the package again you get the initial value again.

To do what you want to do (which I would advise against) you would have to
update the saved package on each run.
Better to get the max value from the table, save it and retrieve in another
table or save it in the registry or ini file.


"effervescent (AT) hotmail (DOT) com" wrote:

Quote:
Hi,

This seems so simple, but I can't figure it out.
I'm trying to keep a 'seed' value in a global variable as an
integer value, essentially a count, to insert as a primary key into a
table. So i created an Integer global variable, set its value to 1. I
loop through some records, doing inserts, incrementing the global
variable. Say I insert 5 records in the first run. I would expect the
global variable to be 6, right? It's still 1. But the records all have
their correct ID's.. 1 - 5. I don't get it. Any ideas?

Thanks!



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.