Home > DeveloperSection > Forums > How To Split From Last Dot In Sql Server?
Manoj Bhatt
Manoj Bhatt

Total Post:153

Points:1079
Posted on    October-27-2014 12:05 AM

 MSSQL Server C#  SQL Server 
Ratings:


 1 Reply(s)
 543  View(s)
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.


Pravesh Singh
Pravesh Singh

Total Post:101

Points:709
Posted on    October-27-2014 12:05 AM

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

Don't want to miss updates? Please click the below button!

Follow MindStick