SQL Server 2000查詢n到m條記錄

來源:互聯網
上載者:User
 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 
相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.