UPDATE nvarchar 结果为 Infinity 或其他意外值
在所有更新字段均为 nvarchar(50) 的表上运行简单的更新查询时,我注意到奇怪的行为。有时(第一个奇怪的事情是什么)我没有得到正确更新的值,而是得到了一些看起来像是某些计算结果的东西。当我再次运行相同的查询时,结果就像我期望的那样。 任何人以前见过它并且知道这个问题的解决方案吗? 请参阅示例:
Query:
UPDATE Tabl1
SET [D1] = '43 / 57.43 %', [D2] = '20 / 41.18 %', [D3] = '145 / 27.50 %',
[D4] = '59 / 28.92 %', [D5] = '143 / 36.44 %', [D6] = '14 / 53.33 %',
[D7] = '0 / 0.00 %', [D8] = '424 / 37.00 %',[D9] = '0 / 0.00 %'
WHERE [key] = 28
Result:
D1 = 100
D2 = 100
D3 = 100
D4 = Infinity
D5 = 41.67
D6 = 100
D7 = 100
D8 = Infinity
D9 = Infinity
提前感谢您的帮助。
While running simple update query on a table where all updated fields are nvarchar(50) I noticed strange behavior. From time to time (what is the first strange thing) instead of getting values properly updated, I get something what looks like a result of some calculation. When I run the same query again it results are like I expect them to be there.
Anyone seen it before and know any solution for this?
Please see example:
Query:
UPDATE Tabl1
SET [D1] = '43 / 57.43 %', [D2] = '20 / 41.18 %', [D3] = '145 / 27.50 %',
[D4] = '59 / 28.92 %', [D5] = '143 / 36.44 %', [D6] = '14 / 53.33 %',
[D7] = '0 / 0.00 %', [D8] = '424 / 37.00 %',[D9] = '0 / 0.00 %'
WHERE [key] = 28
Result:
D1 = 100
D2 = 100
D3 = 100
D4 = Infinity
D5 = 41.67
D6 = 100
D7 = 100
D8 = Infinity
D9 = Infinity
Thanks in advance for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是来自 SQL Server。
SQL Server 没有这样的逻辑来评估计算并返回“Infinity”等字符串。
您必须在表上有执行此重写的触发器,或者您用于提交查询的任何内容重写它。
This isn't coming from SQL Server.
SQL Server has no such logic to evaluate calculations and return strings like "Infinity".
You must have triggers on the table that performs this rewrite or whatever you are using to submit the query rewrites it.