Posts

Showing posts from May, 2023

STRING_AGG (Transact-SQL)

Image
Concatenates the values of string expressions and places separator values between them. The separator isn't added at the end of string. Syntax:      STRING _ AGG ( expression, separator ) [ <order_clause> ] <order_clause> ::= WITHIN GROUP ( ORDER BY <order_by_expression_list> [ ASC | DESC ] ) Arguments expression Is an expression of any type. Expressions are converted to  NVARCHAR  or  VARCHAR  types during concatenation. Non-string types are converted to  NVARCHAR  type. separator Is an expression of  NVARCHAR  or  VARCHAR  type that is used as separator for concatenated strings. It can be literal or variable. <order_clause> Optionally specify order of concatenated results using  WITHIN GROUP  clause: WITHIN GROUP ( ORDER BY <order_by_expression_list> [ ASC | DESC ] ) <order_by_expression_list> A list of non-constant expression...