SQL Server 2000查询n到m条记录
生活随笔
收集整理的這篇文章主要介紹了
SQL Server 2000查询n到m条记录
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
?SQL Server 2000查詢n到m條記錄?
?
(1)select top m * from tablename where id not in (select top n id from tablename) (2). ?????????? select top m * into 臨時(shí)表(或表變量) 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) 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 ??????? 如果你在執(zhí)行select identity(int) id0,* into #temp from tablename這條語句的時(shí)候報(bào)錯(cuò),那是因?yàn)槟??? 的?DB中間的select into/bulkcopy屬性沒有打開要先執(zhí)行: exec sp_dboption 你的DB名字,'select into/bulkcopy',true (5).如果表里有identity屬性,那么簡單: ????????? select * from tablename where identity col between n and m總結(jié)
以上是生活随笔為你收集整理的SQL Server 2000查询n到m条记录的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LDAP身份验证
- 下一篇: CISCO协议总结大全