打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
四种方法取表里n到m条纪录-地主宝宝

--------------------四种方法取表里n到m条纪录: -------------------------

1.
select top m * into 临时表(或表变量) from tablename order by columnname -- 将top m笔插入
set rowcount n
select * from 表变量 order by columnname desc


2.
select top n * from
(select top m * from tablename order by columnname) a
order by columnname desc


3.如果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


4.如果表里有identity属性,那么简单:
select * from tablename where identitycol between n and



Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=660203

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
SQL 查询指定行数的数据
使用存储过程并返回值与及返回值的获得方法
[JAVA]几种流行的数据库SQL分页 - jie
分页的存储过程方法
SQL语句快速入门
总结:六种删除数据库重复行的方法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服