Stored Procedure with simple example using sql server

Simple way to create Stored Procedure 





i. First we need to Create Database  in Sql Server.

       Create  database Employee;

ii. Enter to Database.

       use employee;

iii. Need to Create table with tblemployee.
       create table tblemployee
          (
          Eid int ,
          EName varchar(50),
          Dept varchar(50),
          Salary int 

         )

iv. It shows how to insert values in tblemployee.

     insert into tblemployee values (1,'Ravi','Civil',20000);
     insert into tblemployee values (2,'Raju','Mech',35000);

v. Display all the record of tblemployee.

       select * from tblemployee





















vi. Resultant will be display here:


Same thing can be done in Stored Procedure 

vii. We need to create a Stored Procedure by the name spEmployee to display all record in                       tblemployee.


      create proc spEmployee 
      as
      begin 
      select * from tblemployee;
      end 



viii. This exec/execute command will execute the StoredProcedure.

       exec spEmployee;





ix. Resultant of Stored Procedure :



Hope you all understand the simple example of Stored Procodure ..


Do have any query regarding my code you can comment below !!! 

Post a Comment

0 Comments