January 8, 2016 at 12:23 pm
Hi,
I have a CLR that uses a concatenate function:
https://www.mssqltips.com/sqlservertip/2022/concat-aggregates-sql-server-clr-function/
(andy)
The problem is I am getting duplicates - I know it's supposed to return duplicates, and I know you can eliminate them via SQL side before sending to the CLR but is there a way to eliminate them within the CLR function?
January 8, 2016 at 1:05 pm
krypto69 (1/8/2016)
Hi,I have a CLR that uses a concatenate function:
https://www.mssqltips.com/sqlservertip/2022/concat-aggregates-sql-server-clr-function/
(andy)
The problem is I am getting duplicates - I know it's supposed to return duplicates, and I know you can eliminate them via SQL side before sending to the CLR but is there a way to eliminate them within the CLR function?
Wouldn't you get a better answer if you asked the same question of the author that posted that article?
--Jeff Moden
Change is inevitable... Change for the better is not.
January 8, 2016 at 4:36 pm
I agree with Jeff on asking the author.
However, I also wonder why you want to filter out duplicates at the CLR side. Isn't it more efficient to filter them in the SQL, before even sending them over to the CLR function?
January 8, 2016 at 6:31 pm
Hugo Kornelis (1/8/2016)
I agree with Jeff on asking the author.However, I also wonder why you want to filter out duplicates at the CLR side. Isn't it more efficient to filter them in the SQL, before even sending them over to the CLR function?
I was going to ask the author that very question along with "Where's the performance comparisons against the T-SQL methods"? A lot of people that have written articles on SQLCLR methods get all knocky about their code so dunno if I'll bother.
--Jeff Moden
Change is inevitable... Change for the better is not.
January 9, 2016 at 10:06 am
This group-concat SQLCLR aggregate generally outperforms the XML techniques available in T-SQL:
http://groupconcat.codeplex.com
The code on the site has test scripts comparing it to the XML techniques if you want to try it. Aaron Bertrand also did some test timings with it and found the SQLCLR edged out the XML PATH T-SQL but that is not even the slowest XML technique, XML PATH TYPE has that distinction:
http://sqlperformance.com/2014/08/t-sql-queries/sql-server-grouped-concatenation
I like the tightness of the syntax available using the SQLCLR aggregate when compared to the XML techniques but admittedly I am a bit biased.
There are no special teachers of virtue, because virtue is taught by the whole community.
--Plato
January 9, 2016 at 12:59 pm
Thanks for the links, Orlando.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply