Monday, April 11, 2011

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


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

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.


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


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...