Update string-agg-transact-sql.md#7177
Conversation
Added a note that WITHIN GROUP is only available in compat level 110 or later. You can verify this with the script below. The first SELECT fails, the second succeeds. SELECT o.name, string_agg(c.name, ',') WITHIN GROUP (ORDER BY c.name) FROM sys.objects o JOIN sys.columns c ON o.object_id = c.object_id GROUP BY o.name go ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 110 go SELECT o.name, string_agg(c.name, ',') WITHIN GROUP (ORDER BY c.name) FROM sys.objects o JOIN sys.columns c ON o.object_id = c.object_id GROUP BY o.name go
|
@sommarskog : Thanks for your contribution! The author(s) have been notified to review your proposed change. |
|
Hi @sommarskog , Thanks very much for submitting this suggestion. I actually have a current internal Pull Request open which adds a note to this article specifying that:
We are also adding a related note to the primary compatibility level article. I think that will resolve your issue here, although the wording is slightly different? My PR has some additional changes in it, updating code samples to make them current, so it has taken a bit of time to get through the review process with the holidays. I'll reference this PR on that one and see if I can get it signed off and completed this week. Thanks again, |
|
Apologies for the delay in updating this. This was completed and published in an internal PR and the change is now live. We went with a slightly different wording ("<order_clause> is available with database compatibility level 110 and above.") and we also updated the ALTER DATABASE compatibility level page with the information that Thanks for your patience and for submitting this to us, @sommarskog ! We really appreciate it. Kendra from the Database Docs team |
Added a note that WITHIN GROUP is only available in compat level 110 or later. You can verify this with the script below. The first SELECT fails, the second succeeds.
SELECT o.name, string_agg(c.name, ',') WITHIN GROUP (ORDER BY c.name)
FROM sys.objects o
JOIN sys.columns c ON o.object_id = c.object_id
GROUP BY o.name
go
ALTER DATABASE CURRENT SET COMPATIBILITY_LEVEL = 110
go
SELECT o.name, string_agg(c.name, ',') WITHIN GROUP (ORDER BY c.name)
FROM sys.objects o
JOIN sys.columns c ON o.object_id = c.object_id
GROUP BY o.name
go