Skip to content

Update string-agg-transact-sql.md#7177

Closed
sommarskog wants to merge 1 commit intoMicrosoftDocs:livefrom
sommarskog:patch-1
Closed

Update string-agg-transact-sql.md#7177
sommarskog wants to merge 1 commit intoMicrosoftDocs:livefrom
sommarskog:patch-1

Conversation

@sommarskog
Copy link
Copy Markdown
Contributor

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

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
@PRMerger10
Copy link
Copy Markdown
Contributor

@sommarskog : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@LitKnd
Copy link
Copy Markdown
Contributor

LitKnd commented Jan 10, 2022

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:

<order_clause> is available with database compatibility level 110 and above.

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,
Kendra from the Database Docs Team

@ktoliver ktoliver added the aq-pr-triaged tracking label for the PR review team label Jan 10, 2022
@LitKnd
Copy link
Copy Markdown
Contributor

LitKnd commented Mar 3, 2022

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 <order_clause> is available in compatibility level 110 and higher.

Thanks for your patience and for submitting this to us, @sommarskog ! We really appreciate it.

Kendra from the Database Docs team
#please-close

@PRMerger5 PRMerger5 closed this Mar 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants