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
What is data relation in ado.net?
Explain why canot we use multiple inheritance and garbage collector paralelly in .net?
How do you update a dataset in ado.net and how do you update database through dataset?
What is difference between sqldatareader and sqldataadapter?
Can you explain how to enable and disable connection pooling?
Which method in OLEDBAdapter is used to populate dataset with records?
Which database is the ado.net?
What is the difference between Optimistic and Pessimistic locking?
What is ambient transaction?
What are the advantages and disadvantages of using datalist?
Which is the best method to get two values from the database?
What is a non query?
What is oledb connection?
What are the different methods available under the sqlcommand class to access the data?
Explain the different row versions available in table?