Guest User

Untitled

a guest
Jun 17th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. CREATE PROCEDURE [dbo].[getstores] @lat float, @lng float AS
  2. DECLARE @radius float, @DegToRad float
  3. SET @DegToRad = 57.29577951
  4. SET @radius = 25000
  5. SELECT TOP 10
  6. name
  7. ,sto_lat
  8. ,sto_lng
  9. ,postcode
  10. ,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
  11. FROM store
  12. WHERE (sto_lat >= @lat - (@radius/111))
  13. And (sto_lat <= @lat + (@radius/111))
  14. AND (sto_lng >= @lng - (@radius/111))
  15. AND (sto_lng <= @lng + (@radius/111))
  16. AND (
  17. ISNUMERIC(sto_lat) = 1
  18. AND
  19. ISNUMERIC(sto_lat) = 1
  20. )
  21. ORDER BY distance
Add Comment
Please, Sign In to add comment