日期:2014-05-18 浏览次数:20597 次
select seq=row_number()over(order by getdate()),* from tb
------解决方案--------------------
create sequence seq; select seq.nextval seq,id,shopID from test;
------解决方案--------------------
select id=identity(int,1,1), id,shopID into #tb from test select * from #tb
------解决方案--------------------
--> 测试数据:[test]
if object_id('[test]') is not null drop table [test]
create table [test]([id] int,[shopID] int)
insert [test]
select 44,1 union all
select 45,3 union all
select 49,4 union all
select 50,8 union all
select 53,4
select seq=(select COUNT(1)
from test b where b.ID<=a.ID),
* from test a
/*
seq id shopID
---------------------
1 44 1
2 45 3
3 49 4
4 50 8
5 53 4
*/
--在另外一个帖子已经恢复,没看见???