SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


CLR Aggregate to Concatenate delimited strings


CLR Aggregate to Concatenate delimited strings

Author
Message
gvarol
gvarol
Valued Member
Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)Valued Member (74 reputation)

Group: General Forum Members
Points: 74 Visits: 356
Comments posted to this topic are about the item CLR Aggregate to Concatenate delimited strings
david.wright-948385
david.wright-948385
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1544 Visits: 991
wouldn't


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



be a lot simpler?
Orlando Colamatteo
Orlando Colamatteo
One Orange Chip
One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)One Orange Chip (25K reputation)

Group: General Forum Members
Points: 25198 Visits: 14411
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
Iwas Bornready
Iwas Bornready
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18714 Visits: 885
Thanks for the script.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search