Wednesday, April 27, 2011

FUNCTION & PROCEDURE Differences

.
                     FUNCTION
         PROCEDURE
functions can be used in select or update or delete statement while

A Function can be used in the SQL Queries

The functions are used to do the calculations instead of doing in query

Function should return value


Function can be called from select/where/having clause

The function cannot run independently, It has to be the part of the SQL statement


Function cannot call the stored procedures.


The temporary table cannot be created in the function.

But the function can do only select operation.

Function cannot have the transaction statements.

But the function can create, update and delete the table variable. It can return table variable.

procedure can't


procedure cannot be used in SQL queries 

The stored procedure normally used to perform a speck task. 

Stored procedures may or may not return values

Stored procedure cannot be used in the select/where/having clause

Stored procedure can run independently. It can be executed using EXECUTE or EXEC command

Stored procedure can call the user defined functions

The stored procedure allows us to create the temp tables in the stored procedure.

Stored procedures can have select and all DML operations.

Stored procedure can use transaction statements.

Stored procedures can create table variable and cannot return the table variable.

0 comments:

Post a Comment

Auto Scroll Stop Scroll