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.

Advertisements
Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: