求一SQL?
Name 经度 纬度
南港 1100903 200236
......
生成下表
Name MAP经度 MAP纬度
南港 110.15 20.04
......
即把 度分秒(110度09分03秒) 转换为 110.15度..
------解决方案-------------------- select name,rtrim(left(经度,3))+ '. '+rtrim(substring(经度,4,2)),
rtrim(left(纬度,2)Z)+ '. '+rtrim(substring(纬度,3,2))
from 表
------解决方案--------------------create table #t (name varchar(10),经度 varchar(10),纬度 varchar(10))
insert into #t select '南港 ', '1100903 ', '200236 '
select name,left(经度,len(经度)-4)+ '. '+(cast(right(经度,2) as decimal(10,2))+cast(left(right(经度,4),2) as decimal(10,2))*60)/3600 as MAP经度
,left(纬度,len(纬度)-4)+ '. '+(cast(right(纬度,2) as decimal(10,2))+cast(left(right(纬度,4),2) as decimal(10,2))*60)/3600 as MAP纬度 from #t
drop table #t
---结果
南港 110.1508333 20.0433333