if(@VipCardType='16' or @VipCardType='17' or @VipCardType='20' or @VipCardType='21')
begin
declare @SendType1 varchar(20),@Number int
declare cus_YouHuiQuan cursor--创建游标
for select SendType,Number from tb_CouponRules where VipCardType=@VipCardType group by SendType,Number--查询出结果
open cus_YouHuiQuan--打开游标
fetch cus_YouHuiQuan into @SendType1,@Number
while @@FETCH_STATUS=0--没有下一行就退出
begin
--循环的条件
update tb_CouponDetails set VipID=@VipCard where Pk_PaperID in (select top (@Number) Pk_PaperID from tb_CouponDetails where
ISNULL(VipID,'')='' and UseNum=0 and Sta=1 and PaperType in (@SendType1) order by PaperCode asc);
fetch next from cus_YouHuiQuan into @SendType1,@Number;--执行下一行
end
close cus_YouHuiQuan
deallocate cus_YouHuiQuan
end
begin
declare @SendType1 varchar(20),@Number int
declare cus_YouHuiQuan cursor--创建游标
for select SendType,Number from tb_CouponRules where VipCardType=@VipCardType group by SendType,Number--查询出结果
open cus_YouHuiQuan--打开游标
fetch cus_YouHuiQuan into @SendType1,@Number
while @@FETCH_STATUS=0--没有下一行就退出
begin
--循环的条件
update tb_CouponDetails set VipID=@VipCard where Pk_PaperID in (select top (@Number) Pk_PaperID from tb_CouponDetails where
ISNULL(VipID,'')='' and UseNum=0 and Sta=1 and PaperType in (@SendType1) order by PaperCode asc);
fetch next from cus_YouHuiQuan into @SendType1,@Number;--执行下一行
end
close cus_YouHuiQuan
deallocate cus_YouHuiQuan
end