select *,id=(select count(*) from 表 a where a.id<表.id) from 表
daijingjie2002(艰苦创业) 你的方法不行,提示没有ID
select identity(int , 1, 1) as id , Field1 ,Field2 into NewTable from Table 这方法我知道,求更为简单的方法
可以用临时表 sql2000中是没有直接的方法了 听说sql2005中有函数!
如果table中存在int型的主键列id,则比较简单select (select count(1) from t1 where id<=a.id) as rowid,* from t1 a不然可能只能用identity了 oracle中有伪列rownum,很简单。sql2005好像也会引入分析函数,以后也会变得简单的
select identity(int , 1, 1) as id , Field1 ,Field2 into NewTable from Tableselect * from NewTable注:NewTable为物理表。
回复人: daijingjie2002(艰苦创业) ( ) 信誉:97 2005-01-18 11:50:00 得分: 0
select *,id=(select count(*) from 表 a where a.id<表.id) from 表
你的方法不行,提示没有ID
这方法我知道,求更为简单的方法
sql2000中是没有直接的方法了
听说sql2005中有函数!
oracle中有伪列rownum,很简单。sql2005好像也会引入分析函数,以后也会变得简单的