日期:2014-05-19  浏览次数:20622 次

如何在查询的时候返回一个自增列?
比如返回:
A       B
1       dsfsdf
2       sddsfds
3       dsfsdf
...     ...

类似于   select   identity(1,1),   B   from   tableA

但identity(1,1)是错的,正确的语法是什么?

------解决方案--------------------
select identity(int,1,1) as id,B into newtable from tableA
------解决方案--------------------
select id=identity(int,1,1),b from tablea
------解决方案--------------------
--sql 2005 直接可以用 row_number() over (order by 字段) 方法.
--sql 2000 中 A: 临时表 B: 临时字段 C:关键字生成序号. 这几种方式.