August 12, 2008 at 9:37 am
I am trying to process an entire record set within a For Each Loop container. Within this ForEach Loop I need to create an email for each unqiue value contained in one of the result set variables. I am building my email body by using a For Loop within the ForEach Loop. I am generating an email eachtime the value changes in aone of my variables. I can't get this to work correctly. I seem to be in an endless loop.
August 12, 2008 at 9:54 am
There is nothing wrong with doing that. Slow, but ok. What is your inner loop based on? Which loop seems to be endless. What defines endless? How many rows is the outer and again, then inner looping over? A loop is actually slow(ish) so if you have a loop over 100 rows (or something else) in a loop which is over 1000, that's a whole bunch of loops...
Cheers,CrispinI can't die, there are too many people who still have to meet me!It's not a bug, SQL just misunderstood me!
August 12, 2008 at 10:10 am
I basically create a ResaultSet variable from an exec SQL Task that is ordered by a field called location. I then have a ForEach loop that is used to process the results set. Within the ForEach loop I do the following: Run a script task to build the header for my email body, I then go into a For loop which I would like to loop through all records until the location value changes. For each record with a matching value, I am appending to my email body. When the location changes, I would like to exit the For Loop and generate an email for that specific location. I then continue processing the next location, starting by creating a header and then looping through all rows in the result set for the next uniqure location, and so on until the Result Set is completed.
The vlues used in my For Loop are shown below, and I am simply generating an email with header only infomration"
InitExpression = @varThisSite = @varSite(from result set)
Eval Expression = @varLastSite == @varThisSite
AssignExpression= @varLastSite = @varSite
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply