Sql 操作数数据类型varchar(max)对于除法运算符无效

Sql 操作数数据类型varchar(max)对于除法运算符无效,sql,sql-server,ssms,Sql,Sql Server,Ssms,以下是我尝试使用Microsoft SQL Server Management Studio运行的查询: update [SG report] set [percentage_paid] = ([Savings This Season (All)] / [Savings Goal Amount]) * 100 一个或两个值都是字符串。使用try_convert将它们转换为适当的类型。具体类型不清楚,但大致如下: update [SG report] set [percentage_

以下是我尝试使用Microsoft SQL Server Management Studio运行的查询:

update [SG report] 
set [percentage_paid] = ([Savings This Season (All)] / [Savings Goal Amount]) * 100

一个或两个值都是字符串。使用try_convert将它们转换为适当的类型。具体类型不清楚,但大致如下:

update [SG report] 
    set [percentage_paid] =  (try_convert(float, [Savings This Season (All)])  * 100 /
                              try_convert(float, [Savings Goal Amount])
                             );

您的代码不是有效的SQL。请提供样本数据、期望结果以及您想要做的事情的解释。[SG报告]-数据库表,[支付百分比]-列名,[本季所有储蓄]-列名,[储蓄目标金额]-列的列名数据类型为varcharmax NB:Am使用microsoft sql server management studio 18ISNUMERIC是一个糟糕的函数。它给出了误报和否定。考虑到TRY_CONVERT和TRY_CAST在每个受支持的SQL Server版本中都可用,没有理由不使用它们。谢谢。“我会尽力回答下一个问题的最佳答案。”拉努
update [SG report] 
    set [percentage_paid] =  (try_convert(float, [Savings This Season (All)])  * 100 /
                              try_convert(float, [Savings Goal Amount])
                             );