How to split a comma-separated value to columns

后端 未结 30 4087
刺人心
刺人心 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 05:01

    SELECT id,
           Substring(NAME, 0, Charindex(',', NAME))             AS firstname,
           Substring(NAME, Charindex(',', NAME), Len(NAME) + 1) AS lastname
    FROM   spilt  
    

提交回复
热议问题