Sunday, 3 March 2019

Get last word of a string in sql server

////////////////////// sql script

Declare @Str varchar(100)='this-is-only-for-test',@Para varchar(10)='-'


SELECT substring(@Str,LEN(@Str) - CHARINDEX(@Para,REVERSE(@Str))+2,LEN(@Str)) AS Result



/////////////////result


No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...