For input
A.B.1.23
I want output
A.B.1
For input
A.B.1.23
I want output
A.B.1
In SQL Server, you can use:
select left(col, len(col) - charindex('.', reverse(col)))
This is dynamic and simply assumes that there is at least on '.'
in the column.
See if this helps..
DECLARE @ AS VARCHAR(100) = 'A.B.1.23'
SELECT REVERSE(SUBSTRING(REVERSE(@),CHARINDEX('.',REVERSE(@),0)+1,LEN(REVERSE(@))))
You can use this also :
DECLARE @ AS VARCHAR(100) = 'A.B.1.23'
select substring(@, 1, len(@) - charindex('.', reverse(@)))