日期:2014-05-18 浏览次数:20396 次
create table #tt(id varchar(10)) insert into #tt select 'G000000002' insert into #tt select 'G000000003' insert into #tt select 'G000000004' insert into #tt select 'G000000202' insert into #tt select 'G000000122' select 'G' +replicate('0',len(max(id))-1-len(max(cast(substring(id,patindex('%[1-9]%',id),len(id))as int))+1)) +cast(max(cast(substring(id,patindex('%[1-9]%',id),len(id))as int))+1 as varchar(10)) from #tt ---------------------------- --G000000203 (1 行受影响)