SQL Split function that handles string with delimeter appearing between text qualifiers?

Posted by Ron on Stack Overflow See other posts from Stack Overflow or by Ron
Published on 2010-05-19T14:01:38Z Indexed on 2010/05/20 3:20 UTC
Read the original article Hit count: 594

Filed under:
|
|

There are several SQL split functions, from loop driven, to using xml commands, and even using a numbers table. I haven't found one that supports text qualifiers.

Using the example string below, I would like to split on ",", but not when it appears between double or single quotes.

Example data:

[email protected], "Sally \"Heat\" Jones" <[email protected]>, "Mark Jones" <[email protected]>, "Stone, Ron" <[email protected]>

Should return a table:

[email protected]
"Sally \"Heat\" Jones" <[email protected]>
"Mark Jones" <[email protected]>
"Stone, Ron" <[email protected]>

I know this is a complex query/function, but any suggestions or any guidance would be mucho appreciated.

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql