alter table tablename add sid int identity(1,1) go select * from tablename go alter table tablename drop column sid
算了,中间用了一个javabean过度,找不到办法了
sql2000中没有类似于ROWNUM()这样的函数,但即将推出的sql2005增加了ROWNUM()函数。如果不需要排序,可以用xluzhong(Ralph)的方法。如果需要排序,可以试试下面的sql:CREATE TABLE test ( No int IDENTITY (1, 1) NOT NULL , Value int NULL ) insert test values(6554) insert test values(5444) insert test values(2554) insert test values(7563) insert test values(4568)select(select count(*) from test t2 where t2.Value>t1.Value)+1,Value from test t1 order by Value DESC
go
select * from tablename
go
alter table tablename drop column sid
No int IDENTITY (1, 1) NOT NULL ,
Value int NULL
)
insert test values(6554)
insert test values(5444)
insert test values(2554)
insert test values(7563)
insert test values(4568)select(select count(*) from test t2
where t2.Value>t1.Value)+1,Value
from test t1
order by Value DESC