select sum(isnull(cast(je as float),0)) from [table] GROUP BY spbm去掉rtrim试试
create table tb(je varchar(10),spbm varchar(10)) insert into tb select '223.844 ','aa' insert into tb select '23.44 ','aa' insert into tb select '23.44 ','bb' insert into tb select '223.44 ','bb' insert into tb select '23.44 ','cc'select sum(isnull(cast(Rtrim(je) as float),0)) from [tb] GROUP BY spbmdrop table tb--试了一下好像没什么问题啊
應該是數據庫中有不能轉為float類型的數據。執行這個語句, Select * From [table] Where ISNUMERIC (je)=0 看看有沒有紀錄??
我换成int select spbm, sum(isnull(cast(rtrim(je) as int),0)) from table GROUP BY spbm order by spbm提示还是 将 varchar 值 '25.60' 转换为数据类型为 int 的列时发生语法错误。
将数据类型 varchar 转换为 float 时出错。
insert into tb select '223.844 ','aa'
insert into tb select '23.44 ','aa'
insert into tb select '23.44 ','bb'
insert into tb select '223.44 ','bb'
insert into tb select '23.44 ','cc'select sum(isnull(cast(Rtrim(je) as float),0)) from [tb] GROUP BY spbmdrop table tb--试了一下好像没什么问题啊
Select * From [table] Where ISNUMERIC (je)=0
看看有沒有紀錄??
select spbm, sum(isnull(cast(rtrim(je) as int),0)) from table GROUP BY spbm order by spbm提示还是
将 varchar 值 '25.60' 转换为数据类型为 int 的列时发生语法错误。
因为如果je列中有数据转换错误的话,
只会提示:服务器: 消息 8114,级别 16,状态 5,行 1
将数据类型 varchar 转换为 float 时出错。而不是将 varchar 值 '25.60' 转换为数据类型为 float的列时发生语法错误。楼主执行的是不是不止是这么简单的一条语句阿?