-3
源表:如何分割逗號分隔值成列
Value |name
1 |clar,alwin,antony,rinu,dami,prince
預期輸出:
Value | name1 | name2 | name3 | name4 | name5 | name6
1 | clar | alwin | antony | rinu | dami | prince
嘗試這樣的查詢:
Select Substring(name, 1,Charindex(',', name1) as name1,
Substring(name,1, Charindex(',', name)+1, LEN(name)) as name2,
Substring(name, Charindex(',', name)+2, LEN(name)) as name3,
Substring(name, Charindex(',', name)+3, LEN(name)) as name4
from tablename;
以前被問過很多次,也許試試搜索?! – Tanner
你甚至找到它(我不是downvoter)。 –