HOW TO SPLIT FROM LAST DOT IN SQL SERVER?

Manoj Bhatt

Total Post:154

Points:1086
Posted by  Manoj Bhatt
 807  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. Pravesh Singh

    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))

Answer

NEWSLETTER

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