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 single-user mode?

693


What are the different types of replication are there in sql server 2000?

765


You are designing a strategy for synchronizing an SQL Azure database and multiple remote Microsoft SQL Server 2008 databases. The SQL Azure database contains many tables that have circular foreign key relationships?

113


What is an execution plan? When would you use it?

733


What do we need queues in sql service broker?

702


How to truncate the log in sql server 2012? : sql server database administration

785


What is sql injection and why is it a problem? : sql server security

743


Determine how to use the inserted and deleted pseudo tables?

730


What is correlated subquery in sql server?

749


Can sql servers link to other servers?

756


What is the difference between sql server 2000 object owner and sql server 2005 schema? : sql server database administration

763


How to copy the tables, schema and views from one sql server to another?

741


Does sql server 2000 full-text search support clustering?

675


Mention what are the different types of ssrs reports?

126


Mention the differences between local and global temporary tables.

749