STRING_SPLIT
splits a string into rows
What changes
- Input
- string and one-character separator, optional enable_ordinal
- Output or change
- rowset: value (and ordinal)
- Return type
- If the ordinal output column isn't enabled, STRING_SPLIT returns a single-column table whose rows are the substrings. The name of the column is value. It returns nvarchar if any of the input arguments
Syntax at a glance
STRING_SPLIT ( string , separator [ , enable_ordinal ] )
Work example
Turn a delimited input into rows for a small controlled input format.
Trim each token and validate the delimiter contract before joining parsed values to tables.
Check your work Output order is not guaranteed unless the supported ordinal option is requested and then explicitly ordered.
Practice SQL
Open in SQL FlowSELECT value FROM STRING_SPLIT('red,blue', ',');
Open Microsoft Learn for full syntax, permissions, and details for your version.