以下是试图使用Microsoft Server Server Studio运行的查询:
update [SG report]
set [percentage_paid] = ([Savings This Season (All)] / [Savings Goal Amount]) * 100
update [SG report]
set [percentage_paid] = ([Savings This Season (All)] / [Savings Goal Amount]) * 100
where isnumeric([Savings This Season (All)])=1 and isnumeric([Savings Goal Amount])=1
您的一个或两个值都是字符串。用try_convert()
将它们转换为适当的类型。具体类型尚不清楚,但类似:
update [SG report]
set [percentage_paid] = (try_convert(float, [Savings This Season (All)]) * 100 /
try_convert(float, [Savings Goal Amount])
);