Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

STRING_AGG is not a recognized built-in function name

I've downloaded and installed SQL Server 2016. When I attempted to use the STRING_AGG function I receive this error. Here is my code:

SELECT STRING_AGG(cast(FieldNumber AS VARCHAR(100)), ',')
FROM Fields

I've installed SQL Server 2016 and SP1. Is there anything else I need to do. Here is the feature I am trying to use. String Agg

like image 755
Luke101 Avatar asked Dec 02 '16 01:12

Luke101


People also ask

What is String_agg function in SQL?

STRING_AGG is an aggregate function that takes all expressions from rows and concatenates them into a single string. Expression values are implicitly converted to string types and then concatenated. The implicit conversion to strings follows the existing rules for data type conversions.

When String_agg is introduced in SQL Server?

The STRING_AGG function concatenates strings separated by a specified separator. This was introduced with SQL Server 2017.

Is concat an aggregate function?

The GROUP_CONCAT() function in MySQL is used to concatenate data from multiple rows into one field. This is an aggregate (GROUP BY) function which returns a String value, if the group contains at least one non-NULL value. Otherwise, it returns NULL.

What is aggregate function in SQL Server?

An aggregate function performs a calculation on a set of values, and returns a single value. Except for COUNT(*) , aggregate functions ignore null values. Aggregate functions are often used with the GROUP BY clause of the SELECT statement. All aggregate functions are deterministic.


1 Answers

STRING_AGG is not introduced in SQL SERVER 2016.

It is introduced in SQL SERVER 2017. In the MSDN link you have provided it is mentioned THIS TOPIC APPLIES TO : SQL Server 2017 not SQL SERVER 2016.

At the time of the question, this version was known by the code name "vNext", described as:

SQL Server vNext represents a major step towards making SQL Server a platform that enables choices of development languages, data types, on-premises and in the cloud, and across operating systems by bringing the power of SQL Server to Linux, Linux-based Docker containers, and Windows. SQL Server vNext also includes the features added in SQL Server 2016 service packs

like image 117
Pரதீப் Avatar answered Oct 18 '22 15:10

Pரதீப்