Split comma separated string table row into separate rows using TSQL

后端 未结 3 1167
情歌与酒
情歌与酒 2020-12-18 09:58

Say I have a query that returns the following

ID       SomeValue
1        a,b,c,d
2        e,f,g

Id like to return this as follows:

3条回答
  •  猫巷女王i
    2020-12-18 10:45

    You use cross apply. Something like this:

    select t.id, s.val as SomeValue
    from table t cross apply
         dbo.split(SomeValue, ',') as s(val);
    

提交回复
热议问题