Differnce between Stored procedure and user defined functions?

Answer Posted / santosh kumar

Sl. No. User Defined function Stored Procedure
1 Function must return a value. Stored procedure may or not return values.
2 Will allow only Select statement, it will not allow us to use DML statements. Can have select statements as well as DML statements such as insert, update, delete
etc
3 It will allow only input parameters, doesn’t support output parameters. It can have both input and output parameters.
4 It will not allow us to use try-catch blocks. For exception handling we can use try catch blocks.
5 Transactions are not allowed within functions. Can use transactions within Stored procefures.
6 We can use only table variables, it will not allow using temporary tables. Can use both table variables aswell as temporary table in it.
7 Stored procedures can’t be called from function. Stored Procedures can call functions.
8 Functions can be called from select statement. Procedures can’t be called from Select/Where/Having etc statements. Execute/Exec
statement can be used to call/execute stored procedure.
9 UDF can be used in join clause as a result set. Procedures can’t be used in Join clause

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 the data providers used in ado.net

545


Describe connection object in ado.net

543


What is the full form of ado.net?

510


Describe datareader object of ado.net with example.

511


What is ambient transaction?

508






What is ado and rdo?

504


What is the difference in an abstract class and an interface?

520


Which object is used to add relationship between two Datatables?

580


Where is adodb dll located?

530


describe the dataset object in ado.net.

522


If a table contains 20000 records . In a page at each time 100 records to be displayed what are the steps you will take to improve performance? Will you use dataset or datareader?

620


What is the difference between dataset and datatable?

489


Can datareader hold data from multiple tables?

679


What are the parameters that control most of connection pooling behaviors?

517


What is dataset and datatable in ado.net?

503