This project has moved. For the latest updates, please go here.

Group_Concat String Aggregate for SQL Server: Support for DISTINCT in generated lists

Sep 28, 2016 at 2:38 PM
May anyone help me please in modifying de aggregate function so that it supports a DISTINCT input parameter such as:

dbo.GROUP_CONCAT_DSD(VALUE NVARCHAR(4000), DELIMITER NVARCHAR(10), SORT_ORDER TINYINT, DISTINCT_LIST TINYINT)

Being DISTINCT_LIST a boolean variable having:
  • 1: The resulting list has distinct values.
  • 0: The resulting list has values "as they are".
Thank you :-D :-D :-D

I do not know proper Visual Basic programming, so you would help a lot.

Kind regards
Juan
Coordinator
Sep 29, 2016 at 5:24 AM
No input parameter is required. You can accomplish this with declared SQL, like so from the sample code in Installation Scripts \ Test.2.DemoFunctions.sql:
PRINT '---------- DISTINCT, sorted ASC: CLR GROUP_CONCAT_DS --------------------------------------'
SELECT  DocID,
        dbo.GROUP_CONCAT_DS(DISTINCT ErrorDetail, N',', 1) AS FieldTypeDetail
FROM    dbo.GroupConcatTestData
GROUP BY DocID
ORDER BY DocID ;
Sep 29, 2016 at 8:35 AM
Wow! Thank you! :-D

Didn't thought function would allow also DISTINCT values.

Juan