四种方法取表里n到m条纪录:[转]
生活随笔
收集整理的這篇文章主要介紹了
四种方法取表里n到m条纪录:[转]
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
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 m
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 m
轉(zhuǎn)載于:https://www.cnblogs.com/AlphaWu/archive/2006/05/16/401886.html
總結(jié)
以上是生活随笔為你收集整理的四种方法取表里n到m条纪录:[转]的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GML、SVG、VML的比较
- 下一篇: CSS样式设计1