March 22, 2006 at 7:00 am
Hey all,
Has someone found a good example of using the results from an execute SQL task in a for each loop?
I have a SQL task that returns a row set, linked on completion to a for each task (which will also need another sql task and loop in it to split the comma delimited contents of one column in that initial rowset and loop through them).
So far no matter what configuration settings I use in either task I cannot find the way to access the results from the sql task in the for each loop. Have checked the wrox book and msdn but am missing a detail somewhere.
thanks in advance!
Skål - jh
March 22, 2006 at 12:23 pm
------------------------------
our knight in shining armor
------------------------------
Well! Thank goodness for Brian Knight, he posted the first not-a-file-folder loop example I've been able to find all week. So I finally have a SQL result going into a loop.
http://www.whiteknighttechnology.com/cs/blogs/brian_knight/archive/2006/03/03/126.aspx#comments
Now I'm stuck in that loop getting a paramaterized SQL statement, SELECT LTRIM(RTRIM(textValue)) AS Keyword FROM dbo.fn_ParseText2Table( ?, ','), but setting paramater mapping (SQL_Value | Input | VARCHAR | 0) can't seem to find the value I finally have gotten to work with the for each loop.
Skål - jh
March 22, 2006 at 12:44 pm
You can set the results of a sql statement to a variable of type object, and reference the variable in your for each loop as well......that's how we handle it....it acts like a table variable then.....
March 22, 2006 at 10:58 pm
There are a few ForEach Loop blogs here.
http://sqljunkies.com/WebLog/knight_reign/archive/2005/03/25/9588.aspx
K
March 23, 2006 at 9:43 am
Another here: http://blogs.conchango.com/jamiethomson/archive/2005/07/04/1748.aspx with a downloadable demo.
-Jamie
Jamie Thomson
http://sqlblog.com/blogs/jamie_thomson
March 23, 2006 at 9:50 am
!Fantastico! Thanks guys.
Skål - jh
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply