STRING_SPLIT()
STRING_SPLIT() is a SQL function in the SQL Server Specific category. SQL Server 2016+: splits a delimited string into rows. Returns a single-column table of substrings. The syntax is SELECT value FROM STRING_SPLIT(string, delimiter);. It accepts string, delimiter. It returns table of substrings. A typical example: SELECT value FROM STRING_SPLIT('apple,banana,cherry', ','); -- Returns: -- apple -- banana -- cherry -- Use with IN: SELECT * FROM products WHERE id IN (SELECT value FROM STRING_SPLIT('1,3,5,7', ',')); A close relative is OUTPUT Clause, which sQL Server: returns values from DML statements (like PostgreSQL RETURNING). A close relative is STUFF(), which sQL Server: deletes a specified length of characters from a string and inserts another string at the start position. A close relative is FOR XML PATH, which sQL Server: converts query results to XML format. Commonly used for string concatenation hack. More about this category: SQL Server-specific features — T-SQL, OUTPUT, TOP, PIVOT, STUFF, FOR XML.