Sepertinya Anda mencoba menghitung jarak antara dua titik di Bumi. Buat hidup Anda lebih mudah dan gunakan tipe geografi bawaan.
DECLARE @lat1 DECIMAL(12, 10) ,
@lon1 DECIMAL(12, 10) ,
@lat2 DECIMAL(12, 10) ,
@lon2 DECIMAL(12, 10)
DECLARE @dist FLOAT
SELECT @lat1 = 51.1790825000 ,
@lon1 = 4.1590020000 ,
@lat2 = 51.1790825000 ,
@lon2 = 4.1590020000
DECLARE @p1 GEOGRAPHY = GEOGRAPHY::Point(@lat1, @lon1, 4326) ,
@p2 GEOGRAPHY = GEOGRAPHY::Point(@lat2, @lon2, 4326)
SELECT @dist = @p1.STDistance(@p2)