HOW TO CREATE A STORED PROCEDURE IN MSSQL SERVER

Sachin Singh

Total Post:26

Points:182
Posted by  Sachin Singh
 750  View(s)
Ratings:
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. Anupam Mishra

    Post:135

    Points:949
    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:


Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!