當前位置:
首頁 >
SQL Server 2000查询n到m条记录
發布時間:2025/3/20
33
豆豆
生活随笔
收集整理的這篇文章主要介紹了
SQL Server 2000查询n到m条记录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
?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 臨時表(或表變量) 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 ??????? 如果你在執行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 identity col between n and m總結
以上是生活随笔為你收集整理的SQL Server 2000查询n到m条记录的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: LDAP身份验证
- 下一篇: SQLServer 2005删除无主键表