如何在SQL Server 2008中将逗号分隔值拆分为行 [英] How to split comma separated values into rows in SQL server 2008

查看:96
本文介绍了如何在SQL Server 2008中将逗号分隔值拆分为行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的数据是Rama Brothers,新德里的专栏

我希望输出Rama Brothers在一个专栏中和新德里在另一个专栏中



我尝试了什么:



string_split('Rama Brothers,New Delhi',',')

my data is Rama Brothers, New Delhi in a column
I want the output Rama Brothers in a column and New Delhi in another column

What I have tried:

string_split('Rama Brothers, New Delhi',',')

推荐答案

讨厌:

Nasty:
SELECT LEFT(CsvData, CHARINDEX(',', CsvData)), RIGHT(CsvData, LEN(CsvData) - CHARINDEX(',', CsvData)) FROM MyTable

会这样做,但你最好不要像那样存储你的数据完全没有。

Will do it, but you are much better off not storing your data like that at all.


这篇关于如何在SQL Server 2008中将逗号分隔值拆分为行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆