如何在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.