| 发表于:2007-06-14 17:15:3517楼 得分:0 |
哈哈终于解决了,我查出数据库中web_customerid居然有例如(0000523.)的数据,所以转换成bigint型时就报varchar类型不能转换为bigint 最后的sql语句是: --1:replace(b.web_customerid, '. ', ' ') 排除所有以.结尾的数字,如不排除则报varchar不能转换为bigint类型 --2:convert(bigint, replace(b.web_customerid, '. ', ' '))将所有varchar型数据转换为bigint,自动消除前面的0 --3:left(convert(bigint, replace(b.web_customerid, '. ', ' ')), 6)通过left函数取左边6位字符 --4:最后再将此数据转换为int类型进行对比 --5:isnumeric(web_customerid)将所有不是数字类型的排除 update customerdata set refid_temp=srd_customerid from srd_customerdata b where customerdata.customerid=convert(int,left(convert(bigint, replace(b.web_customerid, '. ', ' ')), 6)) and isnumeric(web_customerid)=1 and isnumeric(srd_customerid)=1 | | |
|