Home > DeveloperSection > Forums > How to create a stored procedure in mssql server
Sachin Singh
Sachin Singh

Total Post:26

Posted on    February-28-2016 9:55 PM

 MSSQL Server Database  SQL Server  SQL  SQL Server 2008  SQL Server 2012  Database Design 

 1 Reply(s)
 621  View(s)
Rate this:
Hi Everyone,

Can anyone tell me what is stored procedure and how to create  stored procedure in ms sql server. In my machine installed  mssql server 2012.
Thank you.

Anupam Mishra

Total Post:135

Posted on    February-29-2016 12:18 AM

Hi Sachin,
Here we are explaining about STORED PROCEDURE:
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 SERVER 2012:
1. User-defined 
2. System
3. Temporary
4. 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:

Stored Procedure:

Now we see all data in Employee table data:

Now, we are executing stored procedure:

Don't want to miss updates? Please click the below button!

Follow MindStick