SQL Select everything after character

前端 未结 6 725
半阙折子戏
半阙折子戏 2021-02-07 07:18

I\'d like to select everything AFTER a certain character (-) that is placed on the most right side.

Eg.

abcd-efgh-XXXX

And I\'d like t

6条回答
  •  我寻月下人不归
    2021-02-07 07:54

    Using string split available from SQLServer 2016

    ;with cte
    as
    (
     select 
    *,row_number() over (order by (select null)) as rownum
     from string_split('abcd-efgh-XXXX','-')
    )
    select top 1 * from cte 
    order by rownum desc
    

提交回复
热议问题