I am using Visual Studio 2015 and having an issue 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 an error SQL46010: Incorrect syntax near AS. Without the
WITHIN GROUP (ORDER BY [Country])
there is no problem.
The target platform is set to
Microsoft Azure SQL Database V12
The debug target connection is set to a local SQL Server vNext database.
Within the SQL Server Management Studio this piece of code executes without any problem. Running the stored procedure within SSMS or from code gives the expected and correct result (1 row per continent with a list of countries per continent separated by commas ordered by country).
Meanwhile I installed Visual Studio 2017 hoping this would eliminate the error, but no luck.
SQL Server Data Tools 17 (build 14.0.61704.140) is installed.
