Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
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: 1080 | Views in the last 30 days: 2
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.


Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones