SQL Server 2000查詢n到m條記錄

2021-09-21 11:15:50 字數 911 閱讀 4781

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 server2000中實現遞迴查詢

要在sql server 2000中實現遞迴查詢,下面示例中給出的乙個地區的乙個遞迴示例,給出上級地區編碼可查詢所有子集地區資訊和本級地區資訊 create table taba pzoneid int,zoneid int create table tabb pzoneid int,zoneid ...

SQLSERVER2000技術規格

sqlserver2000技術規格 系統技術規格 每個伺服器最多可以允許16個sqlserver例項 每個例項可擁有 2147483467 個鎖 資料庫技術規格 sqlserver的資料庫大小1048516tb 每個資料庫可擁有的檔案組數32767 每個資料庫可擁有的檔案組數256 檔案大小 資料檔...

SQLSERVER2000啟動失敗

服務管理器中啟動sqlserver服務 彈出視窗的錯誤資訊是 本地計算機上的mssqlserver服務啟動後又停止了。一些服務自動停止,如果它們沒有什麼可做的,例如 效能日誌和警報 服務 1 解決方法 調整系統時間到你上一次能夠正常啟動的時間,啟動sqlserver服務,成功後,然後再把時間調回來。...