取n到m条记录的语句 1.
select top m * from tablename where id not in (select top n id from tablename) 2.
select top m * into 临时表(或表变量) from tablename order by columnname -- 将top m笔插入
set rowcount n
select * from 表变量 order by columnname desc 3.
select top n * from
(select top m * from tablename order by columnname) a
order by columnname desc
4.如果tablename里没有其他identity列,那么:
select identity(int) id0,* into #temp from tablename 取n到m条的语句为:
select * from #temp where id0 > =n and id0 <= m 如果你在执行select identity(int) id0,* into #temp from tablename这条语句的时候报错,那是因为你的DB中间的select into/bulkcopy属性没有打开要先执行:
exec sp_dboption 你的DB名字,'select into/bulkcopy',true
5.如果表里有identity属性,那么简单:
select * from tablename where identitycol between n and m
select top m * from tablename where id not in (select top n id from tablename) 2.
select top m * into 临时表(或表变量) from tablename order by columnname -- 将top m笔插入
set rowcount n
select * from 表变量 order by columnname desc 3.
select top n * from
(select top m * from tablename order by columnname) a
order by columnname desc
4.如果tablename里没有其他identity列,那么:
select identity(int) id0,* into #temp from tablename 取n到m条的语句为:
select * from #temp where id0 > =n and id0 <= m 如果你在执行select identity(int) id0,* into #temp from tablename这条语句的时候报错,那是因为你的DB中间的select into/bulkcopy属性没有打开要先执行:
exec sp_dboption 你的DB名字,'select into/bulkcopy',true
5.如果表里有identity属性,那么简单:
select * from tablename where identitycol between n and m
解决方案 »
- MS SQL SERVER 2005 数据库大数据量访问(隔离级别设置、并发、性能)问题【加分至600,这个区只能发100】
- 慎用关键字Revert
- 想请大家帮忙解决一个问题谢谢
- 急急急急,数据库锁的问题。
- 请教一个触发器 非常急 大家帮忙吧——送100分
- 存储过程中用什么语句对表的权限进行处理
- 求助:为什么我可以拨号连接到机器,可是却不能访问该sqlserver2000,总是提示sqlstate08001sql不存在或访问被拒绝.
- 在中文2000 操作系统上安装firebird 1.0 ,table 里的数据无法识别中文,(在线等待)
- 全文索引时,如何让查询的关键字中包含点号和不包含一样?
- 如何重建master,win2000 and sql2000????
- 问一个数据库中视图的写法
- 我想问大家一下,怎么实现分类汇总~~很急的,请大家帮我
select top 3 * from tab
where id not in (select top 3 id from tab order by id)
order by id
select top 3 * from tb where bh not in(select top 3 bh from tb)