difference between function and stored procedure in sql server

Posted by Sekar.C under Sql Server on 4/4/2012 | Points: 10 | Views : 39379 | Status : [Member] | Replies : 9
hi,
difference between function and stored procedure in sql server

regards
sekar.c

Regards
Sekar.c



Responses

Posted by: Sakthi.Singaravel on: 4/4/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Sekar,

This link may be helpful for u..
http://www.sqlservercentral.com/Forums/Topic416974-8-1.aspx


Regards,
Singaravel M

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 4/4/2012 [Member] Silver | Points: 25

Up
0
Down
Hi Sekar,

In this link also explain diff., fully:

http://www.c-sharpcorner.com/uploadfile/skumaar_mca/differences-between-procedures-and-functions/


Regards,
Singaravel M

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/4/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

difference between function and stored procedure


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

Procedure allow select as well as Data Manipulation Language statement in it whereas function allow only select statement in it.

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

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


R D Patel

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Patel28rajendra on: 4/4/2012 [Member] Starter | Points: 25

Up
0
Down
Hi

for more details see this link

see this link

http://www.dotnetfunda.com/interview/exam4096-what-is-the-difference-between-stored-procedure-and-function-.aspx



R D Patel

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Savariya on: 4/5/2012 [Member] Starter | Points: 25

Up
0
Down
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

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/13/2012 [Member] Bronze | Points: 25
Posted by: chaitukollati-19140 on: 11/23/2012 [Member] Starter | Points: 25

Up
0
Down
Excelent .......Thanq u

Chaitu

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Tg on: 11/23/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

In function u can use two type of function.
1.Scalar value function
Its for single value retrieve from passing parameter.
2.Table value Function
Its for retrieve Tabla as returning value.

But sp more faster reterival of data.

Sekar.C, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response