Replacing variable length string with some word

前端 未结 2 2050
故里飘歌
故里飘歌 2021-01-03 17:03

Given the below string

Declare @string varchar(max)=\'abc ___________ deffns ___ cg _ hif _______hh ihs\';

this is the Output requi

2条回答
  •  滥情空心
    2021-01-03 17:28

    First get rid of the multiple underscores, then do the replace.

    Here is one method:

    select replace(replace(replace(@string, '_', '><'
                                  ), '<>', ''
                          ), '><', 'LASTNAME'
                  )
    

提交回复
热议问题