Monday, April 11, 2011

.NET and SQL Server Interview Question - Difference between Stored Procedure and Function?

Answer:

Function are compiled and executed at run time.

Stored Procedure are stored in parsed and compiled format in the database.

Function cannot affect the state of the database which means we cannot perform
CRUD operation on the database.

Stored Procedure can affect the state of the database by using CRUD operations.

Store Procedure can return zero or n values whereas Function can return only one
value.

Store Procedure can have input, output parameters for it whereas functions can
have only input parameters.

Function can be called from Stored Procedure whereas Stored Procedure cannot be
called from Function.


Regards,

Please click here to see more .NET and SQL Server interview questions

2 comments:

James said...

I think you failed to mention that functions cannot call non deterministic functions.

Unless they are implemented as a .net clr function of course.

jatin nahar said...

http://dotnetpeoples.blogspot.com/2011/04/stored-procedure-vs-user-defined.html