if object_id('tempdb..#test') is not null drop table #test select identity(int, 1, 1) as 编号, * into #test from 表 select * from #test drop table #test
select 编号=(select count(*)+1 from tablename where 商品名<t.商品名),商品名 from tablename t 或 select 编号=identity(int,1,1),商品名 into #t from tablename select *from #t
select identity(int, 1, 1) as 编号, * into #test from 表
select * from #test
drop table #test
或
select 编号=identity(int,1,1),商品名 into #t from tablename
select *from #t