操作数数据类型 varchar(max) 对于除法运算符无效
Operand data type varchar(max) is invalid for divide operator
下面是我尝试 运行 使用 Microsoft SQL Server Management 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])
);
下面是我尝试 运行 使用 Microsoft SQL Server Management 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])
);