Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

CLR Aggregate to Concatenate delimited strings Expand / Collapse
Author
Message
Posted Friday, January 14, 2011 2:12 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, April 03, 2014 11:29 AM
Points: 20, Visits: 285
Comments posted to this topic are about the item CLR Aggregate to Concatenate delimited strings
Post #1048206
Posted Thursday, January 27, 2011 7:35 AM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Monday, April 14, 2014 2:23 AM
Points: 961, Visits: 717
wouldn't

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

be a lot simpler?
Post #1054577
Posted Tuesday, May 17, 2011 7:43 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 9:25 AM
Points: 7,070, Visits: 12,523
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

Believe you can and you're halfway there. --Theodore Roosevelt

Everything Should Be Made as Simple as Possible, But Not Simpler --Albert Einstein

The significant problems we face cannot be solved at the same level of thinking we were at when we created them. --Albert Einstein

1 apple is not exactly 1/8 of 8 apples. Because there are no absolutely identical apples. --Giordy
Post #1110688
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse