SoftadminUtil.String_Join

Not available in Cloud edition.
Type: Aggregate function

Concatenates all strings in @Value using @Separator as separator. The strings are concatenated according to @SortOrder in ascending order.

In SQL Server 2017 and higher you can use the built-in STRING_AGG function instead.

Example with order by

Gets a string with all user names, ordered by last name.

SELECT
	SoftadminUtil.String_Join(X.Username, ', ', X.RowNumber)
FROM
	(
		SELECT
			Username,
			ROW_NUMBER() OVER (ORDER BY UsernameLast) AS RowNumber
		FROM
			SoftadminApi.[User]
	) X

Return value: nvarchar(max)

The concatenated string or NULL if there are no strings to concatenate (i.e the query returned zero rows).

Parameters

@value mandatory nvarchar(max)
Must not be NULL
@separator mandatory nvarchar(4000)
Must not be NULL
@sortOrder mandatory int
Must not be NULL