How to create a stored procedure in mssql server

Total Post:26

 1157  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.
  1. Post:135

    Re: How to create a stored procedure in mssql server

    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: