title: Advantages of Userdefined functions over Stored Procedures
body: <p>I have some doubt regarding user defined functions. I would like to know why / when to use functions.</p>
  
  <p>What are the advantages of functions over stored procedure? </p>
  
  <p>Researching via google I have seen articles suggesting:</p>
  
  <ul>
  <li>stored procedure are more advantageous than functions.</li>
  <li>function have limited error handling</li>
  <li>functions cannot use temporary tables</li>
  <li>functions cannot call stored procedures.</li>
  </ul>
  
  <p>The only advantage of function is we can use function as inline queries. </p>
  
  <p>I can get the same result with stored procedure by using temporary tables, but i need to know which scenario to use functions compared to stored procedure.
  I need to know why we need UDf , when most of the functionalities provided by UDF can be done by Stored procedure.
  Can any one guide me over this.</p>