select identity(int,1,1) id ,* into #tmp from tablename
有一点要注意,不能将 tablename这个表中的自增长列一并插入到临时表中.
如果是SQLServer 2005 可以使用rownumber
select ROW_NUMBER() OVER (order by Id)as [index],a.id as Id into #temp from tablename
本文介绍如何在 SQL Server 2005 中避免将自增长列插入临时表的方法,并展示了使用 row_number() 函数来为记录生成索引的过程。
select identity(int,1,1) id ,* into #tmp from tablename
有一点要注意,不能将 tablename这个表中的自增长列一并插入到临时表中.
如果是SQLServer 2005 可以使用rownumber
select ROW_NUMBER() OVER (order by Id)as [index],a.id as Id into #temp from tablename

被折叠的 条评论
为什么被折叠?