Created
March 9, 2020 21:38
-
-
Save thdotnet/a70bcfa3858f6ac7f01e6990bb6bf604 to your computer and use it in GitHub Desktop.
T-SQL - GeoDistance sample
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @LAT VARCHAR(10) | |
DECLARE @LONG VARCHAR(10) | |
DECLARE @GEO2 GEOGRAPHY | |
DECLARE @LAT_B VARCHAR(10) | |
DECLARE @LONG_B VARCHAR(10) | |
SET @LAT='29.0' | |
SET @LONG='-95.612528' | |
SET @LAT_B='32.846034' | |
SET @LONG_B='-96.993496' | |
SET @geo2= geography::Point(@LAT_B, @LONG_B, 4326) | |
;WITH X AS | |
( | |
SELECT geography::Point(@LAT, @LONG, 4326) A | |
) | |
SELECT | |
ROUND(@geo2.STDistance(A)/1000, 2) AS KM | |
FROM X |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment