So I think your error is with your select statement.
You are trying to perform calculations on nvarchar values. You either need to change the data types, or perform a Cast within your select statement.
For example…
CAST (lat AS float)
A section from your select statement for example should be…
ACOS( SIN( CAST ((@lat) AS float) * PI() / 180 )
NOTE: With the Cast method you will need to make sure that all you data values are numeric so there will be no cast exceptions
8
solved Error converting data type nvarchar to float