sqlsql-servert-sqlsplit

SQL Server 2016, Invalid object name 'STRING_SPLIT'


In SQL Server 2016 I receive this error with STRING_SPLIT function

SELECT * FROM STRING_SPLIT('a,b,c',',')

Error:

Invalid object name 'STRING_SPLIT'.


Solution

  • Make sure that the database compatibility level is 130

    you can use the following query to change it:

    ALTER DATABASE [DatabaseName] SET COMPATIBILITY_LEVEL = 130
    

    As mentioned in the comments, you can check the current compatibility level of a database using the following command:

    SELECT compatibility_level FROM sys.databases WHERE name = 'Your-Database-Name';