CLR Aggregate to Concatenate delimited strings

  • Comments posted to this topic are about the item CLR Aggregate to Concatenate delimited strings

  • wouldn't

    declare @result varchar(max);

    select @result = coalesce(@result + ',' + value,value) from @codes;

    select @result;

    be a lot simpler?

  • david.wright-948385 (1/27/2011)


    wouldn't

    declare @result varchar(max);

    select @result = coalesce(@result + ',' + value,value) from @codes;

    select @result;

    be a lot simpler?

    I agree your T-SQL solution is simpler than the example code used to demonstrate how the CLR function works, however your T-SQL solution does not bring anything to GROUP BY queries where groups are being processed because COALESCE is not an aggregate function like the CLR function.

    Here is a project containing several CLR User-Defined Aggregate functions that offer similar functionality to the function in the article but that will greatly outperform the function in the article for large datasets:

    http://groupconcat.codeplex.com

    There are no special teachers of virtue, because virtue is taught by the whole community.
    --Plato

  • Thanks for the script.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply