TechnoLearnAcademy

TECHNOLEARN

SQL ALTER STORE PROCEDURE

A STORE PROCEDURES in SQL is a collection of one or more SQL statements or commands that are stored in a database          and can be executed as a single unit.

Syntax:      

                   CREATE PROCECURE procedure_name                                                                                                                                              as                                                                                                                                                                                                        begin                                                                                                                                                                                                         sql_statement                                                                                                                                                                              End;
ALTER STORE PROCEDURE will modify/change the existing store procedure.
Let’s understand the store procedure with an example. For demonstration purposes, we will be using the table emp.
         Table EMP

Example:

   Objective: In this example, we will modify the existing store procedure. We will use the email address as the input                                  parameter instead of ecode.
 ALTER PROCEDURE SP_TEXAS_R(@email as varchar(20))                                                                                                     As                                                                                                                                                                                 Begin                   
                               SELECT e.FirstName, e.LastName , e.Emailaddress, P.Project                                                                                                                         FROM Tbl_Emp as e INNER JOIN Tbl_Project as p                                                                                                                          on e.ecode = p.ecode                                                                                                                                                                        WHERE e.emailaddress= @email
  End
   Execute store procedure:
                      EXEC  SP_PR @email = ‘cynthia.randall@it.frc.com’;
   Output:
Scroll to Top