declare test_Cursor cursor scroll global for select * from fktable
--声明一个游标,加上scroll支持游标向任何方向移动
declare test_Cursor cursor forward_only global
for select * from fktable --默认不加或者forward_only只支持游标向下(next)方向移动
open test_Cursor
declare @id int
declare @scd int
declare @age tinyint
fetch last
from test_Cursor into @id,@scd,@age
print cast(@id as varchar(10))
+‘-----------‘+cast(@scd as varchar(10)) --使用cast可以把整型转换为varchar型然后输出
close test_Cursor
select * from fktable
deallocate test_Cursor --释放游标
--附上参考网址 http://www.cnblogs.com/moss_tan_jun/archive/2011/11/26/2263988.html
原文地址:http://www.cnblogs.com/paulzhangh/p/3750666.html