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 is b tree index?

511


How is sql used in sql server?

497


What is the name of reporting services config file and what’s it’s used for?

107


What are some examples of schemas?

531


How many non clustered indexes there can be on table ?

507






Explain concepts of analysis services?

506


Can we use trigger new in before insert?

514


Explain the phases a transaction has to undergo?

551


What are the restraints imposed on the table design by a merge replication?

564


What is it’s similarity with sql server?

143


How to delete duplicate rows from table except one?

543


How to maintain a fill factor in existing indexes?

528


What are difference between Cluster index and Non-Cluster index?

606


Insert syudents details in table.Current system date &time insert into joining time.How do insert?( in sysdate only return current system date how do add time?)

1427


What are rows and columns?

515