如何查询table中第1000到2000条纪录?

来源:互联网 发布:关键字排名优化 编辑:程序博客网 时间:2024/05/16 11:34

table1(col1 int,col2 varchar(100))

1:如果table1中没有唯一值得列
临时给table1加上一个identity列,查询完后再drop掉
alter table table1 add  NewID int identity(1,1)
select col1,col2 from table1 where NewID>=1000 and NewID<=2000
alter table table1 drop column NewID

2.如果table1中col1的值唯一,也可以如下
select top 2000 * from table1 where col1 not in (select top 1000 col1 from table1)

原创粉丝点击