declare @t table(name varchar(20)) insert @t select '01.02.33' union all select '002.04.50' union all select '004.001.20' union all select '01.0.485' select left(name,len(name)-charindex('.',reverse(name))) from @t
select left([name], charindex('.', [name], charindex('.', [name]) + 1) - 1) from aa
declare @t table(name varchar(20)) insert @t select '01.02.33' union all select '01.2' union all select '002.04.50' union all select '004.001.20' union all select '01.0.485'select case when charindex('.',substring(name,charindex('.',name)+1,len(name)))>0 then left(name,len(name)-charindex('.',reverse(name))) else name end from @t
declare @t table(name varchar(20))
insert @t select '01.02.33'
union all select '002.04.50'
union all select '004.001.20'
union all select '01.0.485'
select left(name,len(name)-charindex('.',reverse(name))) from @t
insert @t select '01.02.33'
union all select '01.2'
union all select '002.04.50'
union all select '004.001.20'
union all select '01.0.485'select
case when charindex('.',substring(name,charindex('.',name)+1,len(name)))>0
then
left(name,len(name)-charindex('.',reverse(name)))
else
name
end
from @t