---
title: "How to create a stored procedure in mssql server"  
description: "How to create a stored procedure in mssql server"  
author: "Sachin Singh"  
published: 2016-02-28  
updated: 2016-02-29  
canonical: https://www.mindstick.com/forum/34010/how-to-create-a-stored-procedure-in-mssql-server  
category: "mssql server"  
tags: ["database", "sql server", "sql", "sql server 2008", "sql server 2012", "database design"]  
reading_time: 2 minutes  

---

# How to create a stored procedure in mssql server

Hi Everyone,\
Can [anyone tell me](https://www.mindstick.com/interview/23033/can-anyone-tell-me-about-hadoop-toolbox) what is [stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net) and how to create stored procedure in ms [sql server](https://www.mindstick.com/articles/12999/what-is-table-valued-function-in-sql-server). In my machine installed [mssql server](https://www.mindstick.com/forum/159376/foreign-key-works-if-we-communicate-with-two-databases-in-mssql-server) 2012.Thank you.

## Replies

### Reply by Anupam Mishra

Hi Sachin,Here we are explaining about **[STORED](https://www.mindstick.com/forum/157561/what-is-the-stored-procedure-create-a-procedure-to-find-the-record-by-stu_id-from-the-student-table) [PROCEDURE](https://www.mindstick.com/forum/32/stored-procedure-return-datatype):**Stored Procedure are a set of SQL statements(one or more) typically grouped together to perform a specific routine. Stored procedure can be created in any user defined database and system database except the resource database. They are comparable to multi statement functions .The most benefits of using stored procedure is as follows:1. Improve performance because they are compiled code 2. easy to maintain \
Stored Procedure is a four types in **[MSSQL](https://www.mindstick.com/forum/168/join-in-mssql-server-2005) [SERVER](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) 2012**:1. User-defined 2. System3. Temporary4. Extended user-defined(replaced by CLR Procedure)\
Here, we are define a simple Stored Procedure to get Name which id i will pass externally :\
Class Structure is as follows:\
![How to create a stored procedure in mssql server](https://www.mindstick.com/mindstickforums/89c9a6f0-5809-4414-9bcd-313f90e06aad/images/b6666337-8fd4-4873-af99-7bd402c77973.png)\
**\****Stored Procedure:****\**![How to create a stored procedure in mssql server](https://www.mindstick.com/mindstickforums/89c9a6f0-5809-4414-9bcd-313f90e06aad/images/3c34905f-6432-4a65-9c68-94e7b64ac8ab.png)**\**\
Now we see all data in **Employee** table data:\
![How to create a stored procedure in mssql server](https://www.mindstick.com/mindstickforums/89c9a6f0-5809-4414-9bcd-313f90e06aad/images/6b334066-a79c-403e-a376-68ded03f8906.png)\
\
Now, we are executing stored procedure:![How to create a stored procedure in mssql server](https://www.mindstick.com/mindstickforums/89c9a6f0-5809-4414-9bcd-313f90e06aad/images/ef4acfc1-5d5b-4a89-a21e-80ab4189aaf3.png)\
\


---

Original Source: https://www.mindstick.com/forum/34010/how-to-create-a-stored-procedure-in-mssql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
