In SQL Server 2016 I receive this error with STRING_SPLIT function
SELECT * FROM STRING_SPLIT(\'a,b,c\',\',\')
Error:
<
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
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.
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! :)