Ich habe eine Antwort in diesem Beitrag gefunden https://gis.stackexchange.com/a/25883/ 37373
Ich habe die Antwort in SQL Server-Code angepasst.
DECLARE @geo as GEOGRAPHY,@newgeo as GEOGRAPHY
SET @geo = (SELECT ZipGeo FROM Location.ZipCodes WHERE ZipCode='90210')
DECLARE @r float,@t float, @w float, @x float, @y float, @u float, @v float;
SET @u=RAND();
SET @v=RAND();
--8046m = ~ 5 miles
SET @r= 8046/(111300*1.0);
SET @w = @r * sqrt(@u);
SET @t = 2 * PI() * @v;
SET @x = @w * cos(@t);
SET @y = @w * sin(@t);
SET @x = @x / cos(@geo.Lat);
SET @newgeo = geography::STPointFromText('POINT('+CAST(@[email protected] AS VARCHAR(MAX))+' '+CAST(@[email protected] AS VARCHAR(MAX))+')',4326)
--Convert the distance back to miles to validate
SELECT @geo.STDistance(@newgeo)/1609.34