Q:

conversion from nvarchar to numeric fails

I am trying to execute this query but the following error is occurring:
Error converting data type nvarchar to numeric

this is my query : 
Select Top 20 *,dbo. GetDistance(35.5,33.8, Longitude, Latitude) as Distance 
From ViewBranchCoordinates
order by Distance desc

if i remove this line order by Distance desc the query run normally with no error
this is the function GetDistance
ALTER FUNCTION [dbo].[GetDistance] 
(
-- Add the parameters for the function here
  @Long decimal(30,24), @Lat decimal(30,24), @Long2 decimal(30,24), @Lat2   decimal(30,24)
)
--decimal(8,6), @Long)
RETURNS decimal(38,28)
AS
BEGIN
-- Declare the return variable here
DECLARE @Distance decimal(38,28)
DECLARE @valueOne decimal(30,24)
DECLARE @valueTwo decimal(30,24)
DECLARE @dLat decimal(30,24)
DECLARE @dLng decimal(30,24)
DECLARE @SectionOne decimal(30,24)
DECLARE @SectionTwo decimal(30,24)

Select @dLat = RADIANS(@Lat - @Lat2)
Select @dLng = RADIANS(@Long -  @Long2)
Select @SectionOne = square(sin((@dLat)/2))
Select @SectionTwo = cos(RADIANS(@Lat)) *  cos(RADIANS(@Lat2)) * square(sin(@dLng / 2))
Select @valueOne =CONVERT(decimal(30,24),@SectionOne + @SectionTwo) 
Select @valueTwo = 2 * ATN2(SQRT(@valueOne), SQRT(1 - @valueOne))
Select @Distance = 6371000 * @valueTwo

RETURN @Distance

END

Any help please

A:

I presume this will fail too? 
 Select Top 20 *
 ,dbo. GetDistance(35.5,33.8, cast (Longitude as decimal (30,24)), cast(Latitude as (30,24)) as Distance 
 From ViewBranchCoordinates

Your function expects data of a certain type.  If your lat/long columns are nvarchar then non numeric data can be in those columns. 
Search for problem data, e.g.
Select *
From ViewBranchCoordinates
Where try_cast (longitude as numeric) IS NULL

Then you need to fix the data.