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 中避免将自增长列一同插入临时表的方法,并提供了使用 rownumber 进行索引的示例。
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

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