|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 6:30 PM
Points: 20,
Visits: 265
|
|
|
|
|
|
SSC Eights!
      
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 4:41 AM
Points: 909,
Visits: 596
|
|
wouldn't
declare @result varchar(max); select @result = coalesce(@result + ',' + value,value) from @codes; select @result;
be a lot simpler?
|
|
|
|
|
SSCertifiable
       
Group: General Forum Members
Last Login: Today @ 8:26 AM
Points: 6,737,
Visits: 11,791
|
|
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
|
|
|
|