标题:怎样取出数据库表中,最后的三条记录?
只看楼主
mingwangxing
Rank: 1
等 级:新手上路
帖 子:36
专家分:0
注 册:2007-5-24
得分:0 

--可以用游标,从倒数第三行向后一行行查询。
declare @a char(10)
declare @b char(10)
declare oneCursor scroll cursor for
select * from table2

open oneCursor
fetch absolute -3 from oneCursor into @a,@b

while (@@fetch_status=0)
begin
print 'a=' + @a + ' b=' + @b
fetch oneCursor into @a,@b
end

close oneCursor
deallocate oneCursor

2007-05-29 01:09



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-140276-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.921404 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved