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'.
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'.
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';
STRING_SPLIT
function. You can build your own function. check this link stackoverflow.com/questions/10914576/t-sql-split-string
SELECT compatibility_level FROM sys.databases WHERE name = 'Your-Database-Name';
May 21, 2019 at 7:36
['DatabaseName']
, and you'll get error message "User does not have permission to alter database". Remember DO NOT add the single quote. Correct way: [DatabaseName]
and you will be able to set the compatibility level
Sep 24, 2021 at 5:05
I was using Split_string
, which felt grammatically correct in English, but my old eyes didn't see that it should be STRING_SPLIT
... so, if you're a bit mentally challenged like me, then check you've typed the command the right way! :)
If you can't change the COMPATIBILITY_LEVEL of the database you are working in, you can try looking at other databases on the same server to find one with a higher COMPATIBILITY_LEVEL. I found that the "master" database on my target server was at COMPATIBILITY_LEVEL = 140, so I connected to that database, and then executed my query, which actually ran against (fully qualified) tables in other databases on the server whose COMPATIBILITY_LEVEL was less than 130. It worked! Just query the various databases on your server with
SELECT compatibility_level FROM sys.databases WHERE name = '<database_name>';
to find one that is >= 130.
You need to change the Compatibility Level of your Database. to do so try below Query and Change you compatibility level to 150.
ALTER DATABASE [Database_Name] SET COMPATIBILITY_LEVEL = 150