select cast (lat as float) lat,long from cs.cs_location where long <>  '' and long is not null and lat<> '' and lat is not null
lat 是字符串纬度信息,都是多少点多少度的,正常情况下是可以转化成FLOAT的。
但该语句出现 非法的varchar 转化 float
但是select count(*) from cs.cs_location where long <>  '' and long is not null and lat<> '' and lat is not null and isnumberic(lat)<> 1
记录集为0 ????
请问各位还有什么情况会导致这种原因啊。 

解决方案 »

  1.   

    奇怪 有没有试试这个是什么结果啊?
    select cast (lat as float) lat,long from cs.cs_location where long <>  '' and long is not null and lat<> '' and lat is not null and isnumberic(lat)= 1
      

  2.   

    select cast (lat as float) lat,long from cs.cs_location where long <>  '' and long is not null and lat<> '' and lat is not null and isnumeric(lat)= 1
    服务器: 消息 8114,级别 16,状态 5,行 1
    将数据类型 varchar 转换为 float 时出错。
    晕死这样子也出错
      

  3.   

    你检查一下lat字段, 一定有一个非数值的值,
    要不你试一个记录,那条cast一定可行,然后再试试全部记录
      

  4.   

    select cast (isnull(lat,0.0) as float) lat,long from cs.cs_location where long <>  '' and long is not null and lat<> '' and lat is not null
      

  5.   

    isnumberic?
    SQL server 里没这个函数啊另外where long <>  '' and long is not null 
    where long <>  ''已经包含了long is not null 这个条件,所以不用加and long is not null
      

  6.   

    select cast ((case ISNUMERIC(lat) when 1 then lat else '0' end) as float) lat,long from cs.cs_location where long <>  '' and long is not null and lat<> '' and lat is not null