title: How do i call a stored procedure or stored function from sql select statement
body: <p>I have created following stored user defined it gets executed successfully.</p>
  
  <pre><code>CREATE FUNCTION spherical_distance1(@a float, @b float, @c float , @Lat float, @Lng float)
  RETURNS float
  AS
  BEGIN
      RETURN ( 6371 * ACOS( COS( @a/@b ) * COS( @Lat/@b ) * COS( @Lng/@b - @c/@b )  + SIN( @a/@b ) * SIN( @Lat/@b )))    
  END
  </code></pre>
  
  <p>The problem i am facing is here, when i call stored function spherical_distance1 ,it shows error like 'spherical_distance1' is not a recognized built-in function name. </p>
  
  <pre><code>SELECT *, spherical_distance1(12.9216667, 57.2958, 77.591667, Lat, Lng) AS distance
  FROM business3 
  WHERE distance &lt; 3
  AND StreetName LIKE '%jayanagar   %'
  AND Keyword LIKE '%plumbing %'
  ORDER BY spherical_distance1(12.9216667, 57.2958, 77.591667, Lat, Lng);
  </code></pre>