Tuesday, August 30, 2011

Difference between stored procedure and functions in SQL Server

Posted by Rahul Kharde at 3:51 AM


Store Procedure

Function

S.P need not be return a value

Functions MUST return a value

S.P can be called independently using exec keyword whereas

Function is called using SELECT statements.

S.P can be used for performing business logic

Functions are used for computations

Can be used EXEC inside an S.P
 

EXEC command can't be used inside a Function

S.P takes IN and OUT parameters.

Function parameters are always IN, no OUT is possible

Transaction related statement can be handled in S.P

Can't be handled in function.

XML parameters passed in S.P

Can’t pass XML Parameters

S.P can affect the state of the database by using insert, delete, update and create operations.

Functions cannot affect the state of the database which means we cannot perform insert, delete, update

Parsed and Compiled during design time itself

Compiled and executed during run time



If you enjoyed this post and wish to be informed whenever a new post is published, then make sure you subscribe to my regular Email Updates. Subscribe Now!


Kindly Bookmark and Share it:

YOUR ADSENSE CODE GOES HERE

0 comments:

Have any question? Feel Free To Post Below:

 

Popular Posts

Recent Comments

© 2011. All Rights Reserved | Help to understand .Net | Template by Blogger Widgets

Home | About | Top