I have a temporary table with a field called Method, thus:
Method will be filled from several rows in another table - CaseEventTypeList.
Turning this into a single comma delimited result is fairly trivial:
Now I need to expand this to take in the entire table. This is what I came up with:
However this only fills Method with the first value from each set of values.
I looked online and found this but would rather not use a udf - especially when the solution feels so close.
UPDATE: The data is fairly simple, the RefId is incremented for each case, the TypeID can be any number, though only 1 to 8 are modelled currently. Thus you might have:
And this will hopefully be modelled as
use this to update the @CaseSites table
You can use a CTE or subquery to correlate and concatenate them the way you want and then do the update.
There are numerous methods of doing the concatenation. Some of them are discussed in Jeff Moden's great article: http://www.sqlservercentral.com/articles/Test+Data/61572/
And there is discussion of wrapping that in a CTE at: http://www.sqlservercentral.com/articles/Common+Table+Expression+(CTE)/62404/
answered Nov 05 '09 at 02:10 PM
workable? Think it does what you want, just replace table names as necessary.