Group_Concat

Returns a string with concatenated values from a group

  • Free Function
  • SQL Server Compatibility: 2008, 2012, 2014, 2016, 2017

Syntax:

SELECT SQLHTTP.net.Group_Concat ( @String, @Delimiter, @Sort )

Arguments:

Name Type Description
@String nvarchar(MAX)

String expression to concatenate into final result. 

Delimiter nvarchar(MAX)

A string, usually a single character such as a comma, to be used a separator between strings. If no delimiter is needed, use an empty string. 

Sort nvarchar(MAX) String expression that determines the sort order of the strings in the final result. See examples below.

Return Type:

nvarchar(MAX)

Sample Usage:

The following table variable is used for the examples below:
List of Continents concatenated using a comma delimiter and sorted alphabetically:
List of Continents concatenated using a comma delimiter and sorted by Countries ascending:
List of Continents concatenated using a comma delimiter and sorted by Countries descending order:

See Also: