借助临时表: select indentity(int,1,1) as id,* into #t from table1 select * from #t order by id; drop table #t;
create table test( id int identity(1,1), col varchar(20) ) insert into test(col) select 'test1' union all select 'test2' union all select 'test3'select right((10000+id),4) as rownum,col from test order by rownumdrop table test
select indentity(int,1,1) as id,* into #t from table1
select * from #t order by id;
drop table #t;
id int identity(1,1),
col varchar(20)
)
insert into test(col)
select 'test1'
union all
select 'test2'
union all
select 'test3'select right((10000+id),4) as rownum,col from test
order by rownumdrop table test