While i was working on one of the upgrade project, we were doing DB upgrade from current DB version to latest version and we faced error like ‘Invalid object name STRING_SPLIT’.
Our Query was as below, [we wanted to spilt ]
DECLARE @StringToSpilt NVARCHAR(50) = 'A;B;C;D'; SELECT value FROM STRING_SPLIT(@StringToSpilt, ';');
Erro: Invalid object name ‘STRING_SPLIT’.
Main reason for this error is compatibility lelvel. This ‘STRING_SPLIT’ function was introduced in SQL Server 2016 and if you are using earlier version then this error will come up.
If you want to use this function, you have to set your SQL Server compatibility of the level to SQL Server 2016 or later version of SQL Server.
ALTER DATABASE [DBNAME] SET COMPATIBILITY_LEVEL = 130 -- For SQL Server 2016 compatibility level GO