Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE [dbo].[getstores] @lat float, @lng float AS
- DECLARE @radius float, @DegToRad float
- SET @DegToRad = 57.29577951
- SET @radius = 25000
- SELECT TOP 10
- name
- ,sto_lat
- ,sto_lng
- ,postcode
- ,ROUND((ACOS((SIN(@lat/57.2958) * SIN(sto_lat/@DegToRad)) +(COS(@lat/@DegToRad) * COS(sto_lat/@DegToRad) *COS(sto_lng/@DegToRad - @lng/@DegToRad))))* 6387.7, 2) AS distance
- FROM store
- WHERE (sto_lat >= @lat - (@radius/111))
- And (sto_lat <= @lat + (@radius/111))
- AND (sto_lng >= @lng - (@radius/111))
- AND (sto_lng <= @lng + (@radius/111))
- AND (
- ISNUMERIC(sto_lat) = 1
- AND
- ISNUMERIC(sto_lat) = 1
- )
- ORDER BY distance
Add Comment
Please, Sign In to add comment