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'.
This typically means 1 of 2 things... you've referenced an object (table, trigger, stored procedure,etc) that doesn't actually exist (i.e., you executed a query to update a table, and that table doesn't exist). Or, the table exists, but you didn't reference it correctly...
Right-click the database, and then select Properties. The Database Properties dialog box opens. In the Select a page pane, select Options. The current compatibility level is displayed in the Compatibility level list box.
Split comma-separated value string in a column. SELECT ProductId, Name, value FROM Product CROSS APPLY STRING_SPLIT(Tags, ','); Here is the result set. The order of the output may vary as the order is not guaranteed to match the order of the substrings in the input string.
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';
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 love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With