表达中的类型转换可能会影响查询计划中的基数估计值
我的执行计划有警告,我无法摆脱。我在这里做了一个最小,可重复的示例:
declare @TestData Table
(
FloatValue float null
)
insert into @TestData values
(null), (0.1)
select
CONVERT(varchar, FloatValue * 100.00) + ' pct.' PctValue
from
@TestData
我包括了警告。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
SQL Server 有时对其警告有点过于谨慎。
您可能会在执行计划中遇到各种警告,经过审查后发现这些警告无关紧要;例如,您有时可能会看到有关内存授予过多的警告,即使该授予实际上是每个查询可能配置的最小量。
由于这不是涉及过滤或加入决策的列,因此您可以放心地忽略它。
SQL Server is sometimes a little over cautious with its warnings.
You can encounter various warnings in the execution plan that, after review, prove to be irrelevant; for example you may sometimes see a warning about an excessive memory grant, even though the grant is literally the minimum configured amount possible per query.
As this is not a column involved with filtering or joining decision making you can safely disregard it.
You can change
CONVERT(varchar, FloatValue * 100.00)
toFORMAT(FloatValue * 100.00, 'N0')
in the query:And it will get rid of the warning:
< a href =“ https://i.sstatic.net/v5nq0.png” rel =“ nofollow noreferrer”>
You can change
CONVERT(varchar, FloatValue * 100.00)
toFORMAT(FloatValue * 100.00, 'N0')
in the query:And it will get rid of the warning: