• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
thankgoodness
博客园    首页    新随笔    联系   管理    订阅  订阅

fetch next from ..用法

declare mmp cursor
for select * from #a
open mmp /*建立cursor与查询数据的关联*/
declare @a1 varchar(50),@a2 varchar(50),@a3 varchar(50),@a4 varchar(100),@a5 varchar(50)
declare @cnt int
select @cnt=0
fetch next from mmp into @a1
while (@@fetch_status=0)--检查是否读取到数据
begin
if @cnt=1 fetch next from mmp into @a2
if @cnt=2 fetch next from mmp into @a3
if @cnt=3 fetch next from mmp into @a4
if @cnt=4 fetch next from mmp into @a5
set @cnt=@cnt+1
end
close mmp

posted @ 2008-05-26 16:15  宇晨  阅读(3549)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3