Sql server 2005 更新case语句中的多个列

Sql server 2005 更新case语句中的多个列,sql-server-2005,cursor,Sql Server 2005,Cursor,我想检查一下,如果赞助商的用户总BV>=50001,那么赞助商的排名、DP、领导力奖金将用特定值更新 如果发起人有一个用户的TotalBV>=50001,则使用第一个case语句中的值更新其记录 如果有2个用户的TotalBV>=50001,则使用第二个case语句中的值更新其记录。。等等 这是我迄今为止所做的,但我在update语句中遇到了错误: declare @UserId varchar(50),@myInt int,@SponsorId varchar(50),@Rank varch

我想检查一下,如果赞助商的用户总BV>=50001,那么赞助商的排名、DP、领导力奖金将用特定值更新

如果发起人有一个用户的TotalBV>=50001,则使用第一个case语句中的值更新其记录

如果有2个用户的TotalBV>=50001,则使用第二个case语句中的值更新其记录。。等等

这是我迄今为止所做的,但我在update语句中遇到了错误:

declare  @UserId varchar(50),@myInt int,@SponsorId varchar(50),@Rank varchar(50),@dp int,@LB int
declare c1 cursor READ_ONLY
for
set @myInt = (select COUNT(User_Id) from UserTransaction as count where @SponsorId='RL9058' and     TotalBV>=50001)

open c1

fetch next from c1
into @SponsorId,@UserId,@Rank

while @@FETCH_STATUS=0
BEGIN

update UserTransaction set Rank,DP,Leadership_Bonus=(case 
when (@myInt=1 and TotalGBV=25000 and TotalPBV=200) then (Rank='executive' and DP=(0.309*BV) and     Leadership_Bonus=(0.07*BV))
when (@myInt=2 and TotalGBV=20000 and TotalPBV=200) then (rank='star executive' and dp=(0.318*BV) and leadership_bonus=(0.03*BV))
when (@myInt=3 and TotalGBV=20000 and TotalPBV=300) then (rank='Organizer' and dp=(0.327*BV) and leadership_bonus=(0.02*BV))
when (@myInt=4 and TotalGBV=15000 and TotalPBV=300) then (rank='Star Organizer' and dp=(0.336*BV) and leadership_bonus=(0.01*BV))
when (@myInt=5 and TotalGBV=15000 and TotalPBV=500) then (rank='Co-Ordinater' and dp=(0.345*BV) and leadership_bonus=(0.01*BV))
when (@myInt=6 and TotalGBV=10000 and TotalPBV=500) then (rank='Star Co-Ordinater' and dp=(0.354*BV) and leadership_bonus=(0.01*BV))
when (@myInt=7 and TotalGBV=10000 and TotalPBV=1000) then (rank='7Star Co-Ordinater' and dp=(0.360*BV) and leadership_bonus=(0.01*BV))
else null end)
where @SponsorId='RL9058'

FETCH NEXT FROM c1
into @UserId,@SponsorId,@Rank,@dp,@LB
END
close c1
DEALLOCATE c1 

错误是:关键字“set”附近的语法不正确,为什么还要为此使用光标??避免像瘟疫一样的诅咒!在这里,你完全可以不用光标,你的代码会更清晰,执行速度也会更快!T-SQL中的CASE是一个计算结果为单个值的表达式-不能返回多个值,也不能执行代码片段。你得重写你的代码我该怎么做?帮助我out@marc_s我没有使用游标也做了这件事,但出现了错误,无法解决它。我认为使用游标将是一个更容易的选择