写两条语句 select convert(int,num) from tab where left(num,1)<>'.' or right(num,1)<>'.' select convert(varchar(6),convert(int,left(num,6)))+'.' from tab where right(num,1)='.'
select convert(int,num) num from tab where left(num,1)<>'.' or right(num,1)<>'.' union all select convert(varchar(6),convert(int,left(num,6)))+'.' num from tab where right(num,1)='.'
自己搞好了 select cast( n.c as int) from (select replace(fieldname,'.','') c from tab) n
select convert(int,num) from tab
else end if
if left(num,2) ='0' THEN right(num,6)
else
........
最后面多了一个小数点
select cast(fieldname as float)
select cast(fieldname as float) 这样不行 因为前面和后面有的有“.”要求把 .0012345 或者 0012345. 或者 0012345 转换成 12345
select convert(int,num) from tab where left(num,1)<>'.' or right(num,1)<>'.'
select convert(varchar(6),convert(int,left(num,6)))+'.' from tab where right(num,1)='.'
union all
select convert(varchar(6),convert(int,left(num,6)))+'.' num from tab where right(num,1)='.'
select cast( n.c as int) from (select replace(fieldname,'.','') c from tab) n