SELECT from 3rd comma in string

后端 未结 4 616
难免孤独
难免孤独 2021-01-14 05:27

I have the following string:

bzip2,1,668,sometext,foo,bar

How can I SELECT only sometext,foo,bar? The length of the string pre

4条回答
  •  一向
    一向 (楼主)
    2021-01-14 06:06

    I just figured out something that works:

    declare @v varchar(max) = 'bzip2,1,668,sometext'
    select substring(@v, CHARINDEX(',', @v, CHARINDEX(',', @v, CHARINDEX(',', @v)+1)+1)+1, len(@v))
    

提交回复
热议问题