34,838
社区成员




create table #a
(
fnumber varchar(255),
fshortNumber varchar(255)
)
Insert into #a
Select 'A01','' union all
Select 'A01.01','' union all
Select 'A01.01.001','' union all
Select 'A01.002','' union all
Select 'A01.002.01.0004',''
update #a set fshortNumber=(Case CharIndex('.',rTrim(fnumber)) When 0 then rTrim(fnumber) Else Right(rTrim(fnumber),CharIndex('.',Reverse(rTrim(fnumber)))-1) End)
create table #a
(
fnumber varchar(255),
fshortNumber varchar(255)
)
Insert into #a(fnumber)
Select 'A01' union all
Select 'A01.01' union all
Select 'A01.01.001' union all
Select 'A01.002' union all
Select 'A01.002.01.0004'
UPDATE #a SET
fshortNumber=RIGHT(fnumber,CHARINDEX('.',REVERSE('.'+fnumber))-1)
select * from #a
drop table #a
UPDATE #a SET
fshortNumber=RIGHT(fnumber,CHARINDEX(REVERSE(fnumber+'.'))-1)