---
title: "What is the difference between function and stored procedure?"  
description: "What is the difference between function and stored procedure?"  
author: "Shikhar Arora"  
published: 2019-12-07  
canonical: https://answers.mindstick.com/qa/92563/what-is-the-difference-between-function-and-stored-procedure  
category: "technology"  
tags: [".net programming"]  
reading_time: 1 minute  

---

# What is the difference between function and stored procedure?

What is the [difference](https://www.mindstick.com/blog/398/difference-between-object-type-and-var-type) between [function](https://www.mindstick.com/articles/43970/purchase-suitable-wedding-dresses-for-your-wedding-function) and [stored procedure](https://www.mindstick.com/articles/202/the-detailed-concept-of-stored-procedure-in-sql-server)

## Answers

### Answer by Sangsaptak Pal

These are basically used in [SQL](https://en.wikipedia.org/wiki/SQL). Function is compiled and executed every time it is called. It cannot modify the data received as parameter and it must return a value. On the other hand, the [stored](https://www.mindstick.com/interview/644/where-is-the-output-of-explain-stored) [procedure](https://www.mindstick.com/blog/304484/explain-the-sql-stored-procedures) is a pre-compiled object as it gets compiled for the first time and its complied format gets stored well. When it is called, it just gets executed.

| Function | Stored Procedure |
| --- | --- |
| It always returns a value | It will not return a value |
| It has only input parameters | It can have both input and output parameters |
| Functions can be called from procedures | Procedures cannot be called from function |
| Transactions cannot be used here | Transactions can be used here |
| Exceptions cannot be handled by try-catch block | Exceptions can be handled by try-catch block |
| It can be used in SELECT statement | It cannot be used in SELECT statement |


---

Original Source: https://answers.mindstick.com/qa/92563/what-is-the-difference-between-function-and-stored-procedure

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
