declare  @id int,@value nvarchar(100);
begin
    declare c_test_main cursor fast_forward for select hps_hpId,hps_time  from  hospitalPermSupp where hps_usId=1;
    open c_test_main;--打开游标
    while 1=1 --开始循环
    begin
        fetch next from c_test_main into @id,@value; --赋值到变量中
        if(@@fetch_status!=0)break;--如果没有结果退出循环
        select @id as a,@value as b
    end
    close c_test_main    --关闭游标
    deallocate c_test_main    --释放游标
end

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。