hi
please see if this what you want !!! hope this helps
please click arrow to the left for Drop CREATE Sample Data
drop table #data
go
create table #data
(
string varchar(100)
)
go
insert into #data select '1.1'
insert into #data select '1.10.1'
insert into #data select '1.2.2.1'
go
select * from #data
go
;with cte as
(
SELECT
string
, CHARINDEX('.',string)+1 FirstIndexof
, CHARINDEX('.',string, (CHARINDEX('.',string)+1)) SecondIndexof
from
#data
)
select
string
, substring(string,1,case when SecondIndexof = 0 then FirstIndexof else SecondIndexof -1 end)
from
cte