SSIS - user variable used in derived column transform is not available - in some cases

Posted by soo on Stack Overflow See other posts from Stack Overflow or by soo
Published on 2010-05-19T20:57:00Z Indexed on 2010/05/19 21:00 UTC
Read the original article Hit count: 126

Filed under:

Unfortunately I don't have a repro for my issue, but I thought I would try to describe it in case it sounds familiar to someone... I am using SSIS 2005, SP2.

My package has a package-scope user variable - let's call it user_var

  1. first step in the control flow is an Execute SQL task which runs a stored procedure. All that SP does is insert a record in a SQL table (with an identity column) and then go back and get the max ID value. The Execute SQL task saves this output into user_var
  2. the control flow then has a Data Flow Task - it goes and gets some source data, has a derived column which sets a column called run_id to user_var - and saves the data to a SQL destination

In most cases (this template is used for many packages, running every day) this all works great. All of the destination records created get set with a correct run_id.

However, in some cases, there is a set of the destination data that does not get run_id equal to user_var, but instead gets a value of 0 (0 is the default value for user_var).

I have 2 instances where this has happened, but I can't make it happen. In both cases, it was just less that 10,000 records that have run_id = 0. Since SSIS writes data out in 10,000 record blocks, this really makes me think that, for the first set of data written out, user_var was not yet set. Then, after that first block, for the rest of the data, run_id is set to a correct value.

But control passed on to my data flow from the Execute SQL task - it would have seemed reasonable to me that it wouldn't go on until the SP has completed and user_var is set. Maybe it just runs the SP, but doesn't wait for it to complete?

In both cases where this has happened there seemed to be a few packages hitting the table to get a new user_var at about the same time. And in both cases lots of data was written (40 million rows, 60 million rows) - my thinking is that that means the writes were happening for a while.

Sorry to be both long-winded AND vague. A winning combination! Does this sound familiar to anyone? Thanks.

© Stack Overflow or respective owner

Related posts about ssis