declare @t table(id varchar(20))insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t select * from @t
insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t
insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t
insert into @t select 'PL'+RIGHT(10001+ISNULL(RIGHT(MAX(id),4),0),4) FROM @t
select * from @t