How to split a comma-separated value to columns

后端 未结 30 3796
刺人心
刺人心 2020-11-21 04:38

I have a table like this

Value   String
-------------------
1       Cleo, Smith

I want to separate the comma delimited string into two colu

30条回答
  •  南笙
    南笙 (楼主)
    2020-11-21 04:58

    I think this is cool

    SELECT value,
        PARSENAME(REPLACE(String,',','.'),2) 'Name' ,
        PARSENAME(REPLACE(String,',','.'),1) 'Sur Name'
    FROM table WITH (NOLOCK)
    

提交回复
热议问题