
Empty substrings are treated the same as are plain substrings.
SPLIT TIMETAG WINDOWS
You can override the final sort order by using an ORDER BY clause on the SELECT statement, for example, ORDER BY value or ORDER BY ordinal.Ġx0000 ( char(0)) is an undefined character in Windows collations and cannot be included in STRING_SPLIT.Įmpty zero-length substrings are present when the input string contains two or more consecutive occurrences of the delimiter character. The order is not guaranteed to match the order of the substrings in the input string. Otherwise, the function will raise an error. It must also be either a bit or int data type with a value of 0 or 1. Note that the enable_ordinal argument must be a constant value, not a column or variable. If enable_ordinal has a value of 1, the function returns a two-column table, including the ordinal column that consists of the 1-based index values of the substrings in the original input string. If enable_ordinal is NULL, omitted, or has a value of 0, STRING_SPLIT returns a single-column table whose rows contain the substrings. STRING_SPLIT outputs a single-column or double-column table, depending on the enable_ordinal argument. Optionally, the function supports a third argument with a value of 0 or 1 that disables or enables, respectively, the ordinal output column. STRING_SPLIT inputs a string that has delimited substrings and inputs one character to use as the delimiter or separator. If the enable_ordinal argument is passed a value of 1, a second column named ordinal is returned that consists of the 1-based index values of each substring's position in the input string.

The length of the return type is the same as the length of the string argument. It returns nvarchar if any of the input arguments are either nvarchar or nchar.

If the ordinal output column is not enabled, STRING_SPLIT returns a single-column table whose rows are the substrings. Beginning with SQL Server 2022 (16.x), the argument and output column are available in SQL Server.

The enable_ordinal argument and ordinal output column are currently supported in Azure SQL Database, Azure SQL Managed Instance, and Azure Synapse Analytics (serverless SQL pool only).
