difference between function and procedure

Answers were Sorted based on User's Feedback



difference between function and procedure..

Answer / ramya

1.a function must returns a value where as procedure may not return value
2.a procedure can have parameters of both i/p and o/p but
fun has only i/p parameters
3.in procedure we can perform all the dml operations but in function only select operation should be performed
4.we call a procedure by using 'exec' or 'execute' command where as function is called by using 'select' command

Is This Answer Correct ?    3 Yes 1 No

difference between function and procedure..

Answer / 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

difference between function and procedure..

Answer / ramya gurrala

Functions:1)Do calculations mostly.
2)Must return value.
3)Calling methods.
4)Function can stand alone.


Procedure:1)Do actions mostly.
2)May or may not return value(the return method is not same as function method).
3)Calling methods.
4)Procedure can not stand alone.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL Server Interview Questions

Syntax to find the used space and free space of the Data file in a database(SQL Server). Following queries didn't give the exact Used space and Free Space Information sp_spaceused;DBCC showfilestats;exec MyDbName.dbo.sp_spaceused;SP_HELPFILE Can any one tell me the query for how to find the exact used data file space and free space in a Data File?

2 Answers   Cognizant,


Explain different types of lock modes in sql server 2000?

0 Answers  


What is dimension table? : sql server analysis services, ssas

0 Answers  


What is change data capture (cdc) feature?

0 Answers  


how would you improve etl (extract, transform, load) throughput?

0 Answers   LinkedIn,






What is the use of stored procedure?

0 Answers  


Explain trigger and its types?

0 Answers  


Explain about thread and memory management process of SQL?

0 Answers  


How to insert data into an existing table?

0 Answers  


How do I view a stored procedure in sql server?

0 Answers  


What is the full form of ddl?

0 Answers  


How to convert binary strings into integers in ms sql server?

0 Answers  


Categories