SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Split Delimited String (Updated: Multi char delimeters)

By tcartwright,

This UDF will take a delimited string and split it into a table. It has an identity field that is provided solely for uniqueness on the rows, but that can be removed to improve the speed, and optimize it. Sample call :

dbo.fnSplit(, )

@Data - the string to split apart
@Delimiter - the seperator string, if DEFAULT or NULL is sent in, a comma will be used. Updated 12-07-02 Now allows for multi character delimters. EX : SELECT * from dbo.fnSplit('test1<|>test2', '<|>') OR SELECT * from dbo.fnSplit('test1##DELIM##test2', '##DELIM##') Or whatever other delimeter your heart desires. Updated : 12-10-02 Fixed a bug if a 10 char delimiter was sent in it would not properly parse the string.

Total article views: 1084 | Views in the last 30 days: 1
Related Articles

Get String between two delimiters

Get string between two delimiters


Delimited String Parser

Parses delimited string into a table of up to 9 varchar fields.


Extracting Rows from Delimited Strings

Extracting Rows from Delimited Strings


Split string using multiple delimiters

This script is used to split the string using multiple delimiters


Delimited String Parsing Functions - Big Set

Feed it large strings of delimited horizontal data and it returns it back as a vertical table.