开发者

SQL Server lat;lng varchar split procedure to use as Lat and Lng for speed Searching

Can someone help me using a stored procedure or function to passing my stored varchar lat;lng in table to individuals fields as float as Lat and Lng to use in radius search.

lanlng in Table
33.0000;15.222222
开发者_StackOverflow中文版

Thanks


Are you just trying to split the string? If so:

declare @LatLng varchar(100)
set @LatLng = '33.0000;15.222222'

declare @Lat float
declare @Lng float

select @Lat = CAST(LEFT(@LatLng, charindex(';',@LatLng)-1) as float)
select @Lng = CAST(SUBSTRING(@LatLng, charindex(';',@LatLng)+1, LEN(@LatLng)-charindex(';',@LatLng)) as float)

select @Lat as Latitude, @Lng as Longitude


SQL Server Zipcode Latitude/Longitude proximity distance search might be of help to you, look at the functions on that page

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜