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

推荐订阅源

博客园 - Franky
D
Docker
Jina AI
Jina AI
The GitHub Blog
The GitHub Blog
博客园 - 聂微东
B
Blog RSS Feed
大猫的无限游戏
大猫的无限游戏
M
MIT News - Artificial intelligence
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
爱范儿
爱范儿
D
DataBreaches.Net
Hugging Face - Blog
Hugging Face - Blog
IT之家
IT之家
Recent Announcements
Recent Announcements
U
Unit 42
腾讯CDC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
宝玉的分享
宝玉的分享
量子位
Stack Overflow Blog
Stack Overflow Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - 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