Yes but what about when you select it through a function? Basically when I call this as a function from a stored procedure it returns the 27.3 or sometimes 0.000000:--Stored procedureSET @Latitude = 53.366103SET @Lomgitude = -2.734406SELECT dbo.fnGetDistance(@Latitude, @Longitude, 53.368770, -2.737818) AS Distance--Stored procedureALTER FUNCTION dbo.fnGetDistance( @lat1 decimal(8,4), @long1 decimal(8,4), @lat2 decimal(8,4), @long2 decimal(8,4)) RETURNS decimal(28,10)AS BEGIN DECLARE @d decimal(28,10) SET @d = 3958.75 * ( Atan(Sqrt(1 - power(((Sin(@lat1/57.2958) * Sin(@lat2/57.2958)) + (Cos(@lat1/57.2958) * Cos(@lat2/57.2958) * Cos((@long2/57.2958) - (@long1/57.2958)))), 2)) / ((Sin(@lat1/57.2958) * Sin(@lat2/57.2958)) + (Cos(@lat1/57.2958) * Cos(@lat2/57.2958) * Cos((@long2/57.2958) - (@long1/57.2958)))))) RETURN @d END
I'm using Visual Studio to do this so don't know if this is also an issue :o\