Thursday 17 September 2015

What is the Difference between Storeprocedure and User Define Function(UDF) in Sqlserver :



 Hello Friends,                                                                                                                          
                  Previous Chapter I have described oop concept in C#.net but now I will expain anther concept in sqlserver i.e What is the difference  between Storeprocedure and Function.
Basically Storeprocedure  is a concept  through which to get /execute the quory on any database server and it can be invoked from any language code and 
                   Function is nothing but  it is a database object which handle different types of functionality.Next chapter I'll briefly describe about Storeprocedure and Function.
Difference between Storeprocedure and User Define Function(UDF):
Store Procedure
User Define Function(UDF)
1
Store procedure is a pre-compiled object ,which are compiled 1st time and it’s code is saved in that area  in which it executes.when it is called it become execute.
1
Function is compiled and executed every time ,when it is called.
2
Procedure can have both  input and out put parameters.
2
But Function  have only input parameter.
3
It is not possible to call procedure from Function.
3
But Function can call from Procedure.
4
Procedure can use select as well as DML(insert,update,delete) Commands or Statements.
4
Function can only use Select statement.
5
Procedure can use Try-Catch block to handle Exception.
5
Function can’t use Try-catch block.
6
Store Procedure may or may not return  any value.
6
Function must return  any value.


I have explained difference between Stored Procedure and Functions (UDF).So after read please Comments and suggestions.
Thanks & Regard
Rabi

No comments:

Post a Comment