昨天的问题.更新异常

zhaozhao110 2007-07-04 10:13:17
update web_user_doorguest set current_datetime=factdatetime,lev=lev+1, [force]=[force]+case when @rand<60 then 1 else case when @rand<85 and @rand>60 then 2 else 3 end end
,[recovery]=[recovery]+case when @rand1<50 then 0 else 1 end ,
[agility]=[agility]+case when @rand2<50 then 0 else 1 end
,[mind]=[mind]+case when @rand3<50 then 0 else 1 end ,
[life]=[life]+case when @rand4<50 then 50 else case when @rand<85 and @rand>50 then 52 else 55 end end where [id]=@id


发现case when 语句,有时会出现问题,就是有的会不执行.
例如force列肯定会加一个数,但有时就不加..是放在服务器上执行.


另外..
update web_user_doorguest set web_user_doorguest.current_life=(case when arm_count>0 then b.current_life else 0 end),web_user_doorguest.state=(case when arm_count>0 then 1 else 5 end)
from #war_temp b where web_user_doorguest.id=b.id and b.type_id=20

还会出现current_life=0,但是state=1的情况.
...全文
545 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
而lev列是更新了的..
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
服务器不是我装的..

和版本 sp都没关系

理解问题,
current_life=(case when arm_count>0 then b.current_life else 0 end)
的结果 current_life=0有两种可能
1 arm_count>0 and b.current_life=0
2 not (arm_count>0)
---------------------------------
update web_user_doorguest set current_datetime=factdatetime,lev=lev+1, [force]=[force]+case when @rand<60 then 1 else case when @rand<85 and @rand>60 then 2 else 3 end end
,[recovery]=[recovery]+case when @rand1<50 then 0 else 1 end ,
[agility]=[agility]+case when @rand2<50 then 0 else 1 end
,[mind]=[mind]+case when @rand3<50 then 0 else 1 end ,
[life]=[life]+case when @rand4<50 then 50 else case when @rand<85 and @rand>50 then 52 else 55 end end where [id]=@id


那就算这里有问题,那这语句是没问题的,数据绝对没错,同样出现错误.有些行的数据就没加值...
昵称被占用了 2007-07-04
  • 打赏
  • 举报
回复
还有一种可能:

3 not (web_user_doorguest.id=b.id and b.type_id=20) and current_life=0
就是说current_life本来是0,这次更新每更新到这条记录,原因是不符合条件
昵称被占用了 2007-07-04
  • 打赏
  • 举报
回复
和版本 sp都没关系

理解问题,
current_life=(case when arm_count>0 then b.current_life else 0 end)
的结果 current_life=0有两种可能
1 arm_count>0 and b.current_life=0
2 not (arm_count>0)
hellowork 2007-07-04
  • 打赏
  • 举报
回复
竟然没打过补丁,胆识可不一般!:)
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
我的是8.00.194 -SQL Server 2000 RTM
hellowork 2007-07-04
  • 打赏
  • 举报
回复
1.使用 select @@VERSION
以下是我机器上的SP4版本信息
Microsoft SQL Server 2000 - 8.00.2039 (Intel X86)
May 3 2005 23:18:38
Copyright (c) 1988-2003 Microsoft Corporation
Enterprise Edition on Windows NT 5.2 (Build 3790: Service Pack 1)

2.使用exec master..xp_msver
paoluo 2007-07-04
  • 打赏
  • 举报
回复
Microsoft SQL Server 系统版本信息查询语句

  Select @@Version;
  然后按执行;
  这时会返回SQL的版本信息,如下:
  Microsoft SQL Server 2000 - 8.00.760 (Intel X86) Dec 17 2002 14:22:05 Copyright (c) 1988-2003 Microsoft Corporation Enterprise Edition on Windows NT 5.0 (Build 2195: Service Pack 3)
  其中的8.00.760就是SQL Server的版本和补丁号。对应关系如下:
  8.00.194 -SQL Server 2000 RTM
  8.00.384 -(SP1)
  8.00.534 -(SP2)
  8.00.760 -(SP3)
8.00.2039-(SP4)
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
那如何知道是否安装了sp4补丁呢?谢谢...
hellowork 2007-07-04
  • 打赏
  • 举报
回复
语句上没问题,先看看服务器端SQL打补丁的情况吧,有时候不打补丁出现的问题千奇百怪。
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
而他也出现了同样类似的问题..
------------------------------------------------
如果本地的SQLSERVER打了补丁运行代码没有问题,而相同的数据在服务器端出现了问题就应该怀疑是服务器端SQLSERVER补丁不齐.
-----------------------------------------------
服务器上会有一千多人在线..压力很大,本地没这种情况,是不是服务器的问题呢?

zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
但问题是第一种数据不会有问题,这个是升级用的...
paoluo 2007-07-04
  • 打赏
  • 举报
回复
zhaozhao110(我死了,在烈火中我又站起来了,你猜是涅盘,还是尸变?) ( ) 信誉:100 Blog 加为好友 2007-7-4 10:27:21 得分: 0



有沒有可能是current_life 本身的值就是0,那麼current_life就有可能為0了。
--------------------------------------------------
这个是有可能的...



-------------------------------

如果有這種可能性,你描述的第二種情況有可能是正常的,你可以仔細的查下。
hellowork 2007-07-04
  • 打赏
  • 举报
回复
如果本地的SQLSERVER打了补丁运行代码没有问题,而相同的数据在服务器端出现了问题就应该怀疑是服务器端SQLSERVER补丁不齐.
sp4 2007-07-04
  • 打赏
  • 举报
回复
看语句本身没有什么问题啊,虽然罗嗦了些
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
update web_user_doorguest set current_datetime=factdatetime,lev=lev+1, [force]=[force]+case when @rand<60 then 1 else case when @rand<85 and @rand>60 then 2 else 3 end end
,[recovery]=[recovery]+case when @rand1<50 then 0 else 1 end ,
[agility]=[agility]+case when @rand2<50 then 0 else 1 end
,[mind]=[mind]+case when @rand3<50 then 0 else 1 end ,
[life]=[life]+case when @rand4<50 then 50 else case when @rand<85 and @rand>50 then 52 else 55 end end where [id]=@id
---------------------------------------------------------
这条语句是写在游标循环里的.数据本身不会有问题,都有初始值.但出现有些属性不增加.的确很郁闷,
对了sp4补定对这个有影响吗?
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
有沒有可能是current_life 本身的值就是0,那麼current_life就有可能為0了。
--------------------------------------------------
这个是有可能的...
hellowork 2007-07-04
  • 打赏
  • 举报
回复
看看服务器上的SQLSERVER是不是打了SP4补丁,语句本身没有问题.
paoluo 2007-07-04
  • 打赏
  • 举报
回复
看語句,按道理,應該是不會的。
zhaozhao110 2007-07-04
  • 打赏
  • 举报
回复
update web_user_doorguest set web_user_doorguest.current_life=(case when arm_count>0 then b.current_life else 0 end),web_user_doorguest.state=(case when arm_count>0 then 1 else 5 end)
from #war_temp b where web_user_doorguest.id=b.id and b.type_id=20

还会出现current_life=0,但是state=1的情况.
----------------
有沒有可能是current_life 本身的值就是0,那麼current_life就有可能為0了。
---------------------------------------------------------------------
这是我写的一存储过程里的一条语句,过程有一千多行..在服务器上偶而就会出错,本地没发现..
加载更多回复(4)

34,873

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧