[英]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. 我“googled”,发现了一个神奇而优雅的SQL查询,将逗号分隔的输入字符串拆分为单列中的行。 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. 它使用
select into
或insert into
结合select
, coalesce()
以及where
创建行,每个值对应一个字符串。
There are plenty of examples using coalesce()
to form a string but none (any more) to split it. 有很多例子使用
coalesce()
来形成一个字符串但没有(再也没有)来分割它。 I've also found this solution for the meantime: 我也在此期间找到了这个解决方案:
http://www.sqlservercentral.com/articles/T-SQL/62867/ 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()
? 有没有人看过如何用
coalesce()
拆分字符串? If so, how does its performance compare to the various sql string splitters that have been studied and compiled? 如果是这样,它的性能如何与已经研究和编译的各种sql字符串分割器相比较?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.