简体   繁体   中英

Split comma-separated string in T-SQL using Coalesce()?

I "googled" and found a magical and elegant sql query to split a comma-separated input string into rows in a single column. Doing so allows a join instead of a "where in". It used a select into or insert into combined with a select , coalesce() and where to create rows, one for each value in the string.

There are plenty of examples using coalesce() to form a string but none (any more) to split it. I've also found this solution for the meantime:

http://www.sqlservercentral.com/articles/T-SQL/62867/

But I'm curious now, that I cannot "regoogle" for the gem I found before (about a year ago).

Has anyone seen how to split a string with coalesce() ? If so, how does its performance compare to the various sql string splitters that have been studied and compiled?

COALESCE simply returns the first non-null value from a group of expressions. It would not perform any magical splitting of a delimited string.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM