difference between function and procedure

Answer Posted / manub22

- Stored Procedures can contain a single SQL statement or a group of SQL statements with data flow control logic containing IF-ELSE, WHILE loop constructs, TRY-CATCH, transactions, etc.
SPs are used to return one or many result-sets to its calling application.

- On the other hand Functions or UDFs can contain single or multiple SQL statements depending on its type. A Scalar UDF & Inline UDF can only have a single SELECT statement. And a Multi-Statement UDF can contain a body with multiple SQL statements including SELECTS, IF-ELSE, WHILE loops and DMLs but limited to manipulating table variables only.
UDFs return a single Scalar value or a Table variable to the calling SELECT statement.

Check all the difference here:
http://sqlwithmanoj.com/2011/09/21/stored-procedures-vs-functions-difference-between-sp-udf/

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are different types of views?

557


Can a trigger be created on a view?

577


what are database files and filegroups? : Sql server database administration

505


What is indexing explain it with an example?

555


How do you rename a table in sql server?

495






What are the properties of the transactions?

616


How do I uninstall sql server 2014?

525


What are indexers?

631


What is an indice?

577


What are the advantages of sql azure?

116


What is full outer join in sql server joins?

571


How to modify existing triggers using "alter trigger"?

531


What is a join in sql? What are the types of joins?

525


List some major differences between triggers and stored procedures?

524


You have to store user responses of ‘yes’ and ‘no’ what kind of data type is best suited for this task?

534