惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
M
MIT News - Artificial intelligence
量子位
N
Netflix TechBlog - Medium
The Cloudflare Blog
The GitHub Blog
The GitHub Blog
P
Proofpoint News Feed
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
B
Blog
博客园_首页
博客园 - Franky
MyScale Blog
MyScale Blog
有赞技术团队
有赞技术团队
Apple Machine Learning Research
Apple Machine Learning Research
MongoDB | Blog
MongoDB | Blog
云风的 BLOG
云风的 BLOG
爱范儿
爱范儿
H
Help Net Security
Y
Y Combinator Blog
Stack Overflow Blog
Stack Overflow Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
酷 壳 – CoolShell
酷 壳 – CoolShell

博客园 - dragonpig

Html 5 Canvas绘制分形图Mandelbrot .net中反射、emit、expression和dynamic的性能比较 const string 和 static readonly string的区别 SqlServer: Top N per Group 微软的BinarySearch 通过SQL CTE计算Fibonacci 当json.js遇见dynamic.net烂尾篇 .NET线程安全泛型Singleton 跨域访问Cookie WCF JSON和AspnetCompatibility的配置 Windows安装Memcached node.js初体验 教你如何制作Silverlight Visual Tree Inspector 一道非常有趣的概率题 教你30秒打造强类型ASP.NET数据绑定 当json.js遇见dynamic.net [0] 用Silverlight做雷达图 C#运算符重载不是没有用武之地 随机排列算法
通过CTE实现Split CSV
dragonpig · 2011-03-02 · via 博客园 - dragonpig

declare @text nvarchar(500)
,
@delimiter nchar(1)
set @text = '1,2,3'
set @delimiter = ','
set @text = @text + @delimiter
;
WITH CSV([index], [comma_index])
as(
select [index] = 1, [comma_index] = CHARINDEX(@delimiter, @text)
union all
select [index] = [comma_index] + 1, [comma_index] = CHARINDEX(@delimiter, @text, [comma_index] + 1)
from csv
where CHARINDEX(@delimiter, @text, [comma_index] + 1) <> 0
)
select SUBSTRING(@text, [index], [comma_index] - [index])
from CSV
where comma_index <> 0

参考前文。 ‘1,2,3’ 将被分解为

1

2

3