--------------------四種方法取表里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
如果你在執(zhí)行select identity(int) id0,* into #temp from tablename這條語句的時候報錯,
那是因為你的DB中間的select into/bulkcopy屬性沒有打開要先執(zhí)行:
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