---
title: "Difference between Stored Procedure and Function"  
description: "In this blog I am going to explain the basic difference between Stored Procedure and Function.Stored procedures:Have to use EXEC or EXECUTE.  Return"  
author: "Chris Anderson"  
published: 2011-11-30  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/270/difference-between-stored-procedure-and-function  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# Difference between Stored Procedure and Function

In this blog I am going to [explain the basic](https://www.mindstick.com/forum/160087/explain-the-basic-structure-of-a-json-object) [difference between Stored](https://www.mindstick.com/forum/33/difference-between-stored-procedure-and-function) Procedure and Function.

##### Stored procedures:

· Have to use EXEC or EXECUTE.\
· Return output parameter.\
· You can create table but won't return Table Variables.\
· You cannot join [stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net).\
· Can be used to change server configuration.\
· Can be used with XML FOR Clause.\
· Can have transaction within stored procedure.\
· Procedures can be used for performing business logic.\
· [Stored Procedures](https://www.mindstick.com/forum/540/using-stored-procedures-with-entity-framework-in-an-asp-dot-net-application) takes input, output parameters.\
· Stored Procedures cannot be called directly into DML statements.\
· Procedure may return one or more values through parameters or may not return at all.\
· Procedure can return [multiple values](https://www.mindstick.com/forum/399/how-to-insert-multiple-values-selected-in-checkbox-in-database) (max 1024).\
· Stored procedure returns always integer value by default zero.\
· Stored procedure is precompiled execution plan.\
· Procedure cannot be used in SQL queries.\

##### Functions:

· Can be used with [Select statement](https://www.mindstick.com/forum/160076/explain-the-sql-select-statement-and-how-it-s-used-to-search-for-data-in-a-database).\
· Not returning output parameter but returns Table variables.\
· We can join UDF (user [defined function](https://www.mindstick.com/interview/2294/what-is-the-difference-between-a-user-defined-function-and-a-stored-procedure)).\
· Cannot be used to change server configuration.\
· Cannot be used with XML FOR clause.\
· Cannot have transaction within function.\
· Functions are used for computations.\
· Function takes only input parameters.\
· Functions can be called directly into DML statements.\
· A FUNCTION is always returns a value using the [return statement](https://answers.mindstick.com/qa/82430/why-do-we-use-return-statement-in-c-sharp).\
· A Function returns 1 value only.\
· Whereas function returns type could be scalar or table or table values.\
· A function can call directly by SQL statement like select func_name from dual.\
· A Function can be used in the SQL Queries.\

---

Original Source: https://www.mindstick.com/blog/270/difference-between-stored-procedure-and-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
