- 方法一
1
SELECT Row_Number() over ( order by getdate() ) as init , * FROM 表名
- 方法二
使用关键字IDENTITY创建临时表1
SELECT IDENTITY(int,1,1) as Nid,* INTO #T FROM 表名 SELECT * FROM #T
Sql Server查询结果中添加自增列
使得梯云纵 方能水上漂
1 | SELECT Row_Number() over ( order by getdate() ) as init , * FROM 表名 |
1 | SELECT IDENTITY(int,1,1) as Nid,* INTO #T FROM 表名 SELECT * FROM #T |