Problem with STRING_AGG WITHIN GROUP and Visual Studio

I am using Visual Studio 2015 and have a problem in my SQL Server database project with STRING_AGG WITHIN GROUP.

SELECT [Continent], 
STRING_AGG([Country], ', ') WITHIN GROUP (ORDER BY [Country]) AS CountryList
FROM [Country]
GROUP BY [Continent]

This code gives error SQL46010: Incorrect syntax near AS. Without

WITHIN GROUP (ORDER BY [Country])

no problems.

Destination platform installed on

Microsoft Azure SQL Database V12

The target debug connection is established in the local SQL Server vNext database.

In SQL Server Management Studio, this piece of code runs without any problems. Running the stored procedure in SSMS or from the code gives the expected and correct result (1 line per continent with a list of countries on the continent, separated by commas, sorted by country).

Meanwhile, I installed Visual Studio 2017, hoping this fixes the error, but no luck.

SQL Server 17 data tools installed (build 14.0.61704.140).

+4
2

, , , . , , SQL Server COMPATIBILITY_LEVEL, . https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-database-transact-sql-compatibility-level?view=sql-server-2017 , .

SELECT NAME, COMPATIBILITY_LEVEL FROM sys.databases; , COMPATIBILITY_LEVEL 100 (.. SQL Server 2008).

ALTER DATABASE SET COMPATIBILITY_LEVEL = 110 ( 120 130), SQL Server 2012+, , WITHIN GROUP STRING_AGG, .

+1

Visual Studio 2017, :

msgstr " ')'". STRING_AGG() WITHIN GROUP().

, " ->" " Visual Studio.

SQL Server 2017, . , Visual Studio 2017 SQL Server 2016.

0

Source: https://habr.com/ru/post/1675610/


All Articles