What is difference between stored procedure & function?

Answers were Sorted based on User's Feedback



What is difference between stored procedure & function?..

Answer / khurram

1>Procedure can return zero or n values whereas function can
return one value which is mandatory.

2>Procedures can have input,output parameters for it whereas
functions can have only input parameters.

3>Procedure allow select as well as DML statement in it
whereas function allow only select statement in it.

4>Functions can be called from procedure whereas procedures
cannot be called from function.

5>Exception can be handled by try-catch block in a procedure
whereas try-catch block cannot be used in a function.

6>We can go for transaction management in procedure whereas
we can't go in function.

7>Procedures cannot be utilized in a select statement
whereas function can be embedded in a select statement.

Is This Answer Correct ?    17 Yes 3 No

What is difference between stored procedure & function?..

Answer / shreenath27@yahoo.co.in

function will return value but procedure will not return any
value

Is This Answer Correct ?    6 Yes 4 No

What is difference between stored procedure & function?..

Answer / somu kattikar

Functions
----------
1) can be used with Select statement
2) Not returning output parameter but returns Table
variables
3) You can join UDF
4) Cannot be used to change server configuration
5) Cannot be used with XML FOR clause
6) Cannot have transaction within function

Stored Procedure
-----------------
1) have to use EXEC or EXECUTE
2) return output parameter
3) can create table but won’t return Table Variables
4) you can not join SP
5) can be used to change server configuration
6) can be used with XML FOR Clause
7) can have transaction within SP

Is This Answer Correct ?    1 Yes 1 No

Post New Answer

More SQL Server Interview Questions

how to invoke a trigger on demand? : Sql server database administration

0 Answers  


what's the difference between a primary key and a unique key? : Sql server database administration

0 Answers  


Do you know what is a trace frag? Where do we use it?

0 Answers  


What are the different types of collation sensitivity?

0 Answers  


Can a function call a stored procedure in sql server?

0 Answers  






One table how may column and Primary key

3 Answers  


You want to check the syntax of a complicated update sql statement without executing it. What command should you use?

0 Answers  


How to enable/disable indexes?

0 Answers  


how to get the maximum among two tables,for example table 1 (dep1) have (emp_id,emp_name,salary) columns and table 2 (dept2) have (emp_id,emp_name,salary) columns,i want which employee have the maximum salary among two tables?

9 Answers   Deloitte, Lason,


What is meant by datasource?

0 Answers  


How to Improve the performencs of SQL Server 2005 exclude stored Procedure and Indexes?

0 Answers  


What samples and sample databases are provided by microsoft?

0 Answers  


Categories