---
title: "What is Difference between STORED PROCEDURE vs FUNCTION?"  
description: "What is Difference between STORED PROCEDURE vs FUNCTION?"  
author: "Anubhav Sharma"  
published: 2026-05-03  
updated: 2026-05-05  
canonical: https://answers.mindstick.com/qa/116565/what-is-difference-between-stored-procedure-vs-function  
category: "database"  
tags: ["database", "sql server"]  
reading_time: 2 minutes  

---

# What is Difference between STORED PROCEDURE vs FUNCTION?

**What is [Difference between STORED](https://www.mindstick.com/forum/33/difference-between-stored-procedure-and-function) [PROCEDURE vs FUNCTION](https://www.mindstick.com/interview/22887/difference-between-procedure-vs-function-in-the-database)?**

## Answers

### Answer by Ravi Vishwakarma

The [difference](https://yourviews.mindstick.com/story/5016/chia-vs-basil-seeds-what-s-the-difference) between a **[Stored Procedure](https://www.mindstick.com/articles/202/the-detailed-concept-of-stored-procedure-in-sql-server)** and a **[Function](https://www.mindstick.com/articles/43970/purchase-suitable-wedding-dresses-for-your-wedding-function)** mainly comes down to how they behave, what they return, and how you use them in SQL.

### 1. Basic Definition

- **Stored Procedure**: A set of SQL statements that performs a task (can include logic, loops, transactions, etc.).
- **Function**: A routine that **must return a value** and is usually used within queries.

### 2. Return Value

**Stored Procedure**:

- May or may not return a value
- Can return multiple values using output parameters

**Function**:

- **Must return exactly one value** (scalar or table)

### 3. Usage in Queries

**Stored Procedure**:

- Cannot be used directly inside `SELECT`, `WHERE`, etc.
- Called using `CALL` or `EXEC`

**Function**:

- Can be used inside SQL statements

   - Example:

```plaintext
SELECT my_function(column_name) FROM table;
```

### 4. Data Modification

**Stored Procedure**:

- Can perform **INSERT, UPDATE, DELETE** operations
- Can manage transactions (COMMIT/ROLLBACK)

**Function**:

- Typically **cannot modify database state** (in most DB systems)
- Mainly used for calculations or data transformation

### 5. Parameters

**Stored Procedure**:

- Supports **IN, OUT, INOUT** parameters

**Function**:

- Usually supports only **input parameters**

### 6. Execution

**Stored Procedure**:

```plaintext
CALL procedure_name();
```

**Function**:

```plaintext
SELECT function_name();
```

### 7. Use Case

**Stored Procedure**:

- Complex business logic
- Batch processing
- Data manipulation

**Function**:

- Calculations
- Formatting values
- Reusable logic in queries

### Quick Summary

| Feature | Stored Procedure | Function |
| --- | --- | --- |
| Return value | Optional / multiple | Mandatory (single) |
| Use in SELECT | No | Yes |
| Data modification | Allowed | Restricted |
| Parameters | IN, OUT, INOUT | Mostly IN only |
| Purpose | Perform actions | Return value |


---

Original Source: https://answers.mindstick.com/qa/116565/what-is-difference-between-stored-procedure-vs-function

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
