How To Split From Last Dot In Sql Server?

Total Post:154

Points:1086
 1089  View(s)
Ratings:
Rate this:
Hi,
The below are the values stored in DB.
2013.ack
2013.regres
2013.zip.ack
Here I need to trim the values before the last dot(.).
The output should be like below
2013.
2013.
2013.zip.
  1. Post:101

    Points:709
    Re: How To Split From Last Dot In Sql Server?

    Hi,
    Please try with below sample 

    DECLARE @Expression NVARCHAR(100)
    SET @Expression = 'abc.test.sd'
    SELECT SUBSTRING(@Expression,1,LEN(@Expression)-(CHARINDEX('.',REVERSE(@Expression))-1))

      Modified On Apr-06-2018 01:15:19 AM

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!