In this article I will explain a tutorial with example on how to modify (Alter) an existing Stored Procedure in SQL Server.

Using this tutorial you can easily modify (Alter) an existing Stored Procedure in all SQL Server versions i.e. 2000, 2005, 2008, 2008R2, 2012 and 2014.

 

Database
Here I am making use of Microsoft’s Northwind Database. The download and install instructions are provided in the following article.
 

Creating a Stored Procedure

Below figure displays the syntax for creating a stored procedure. As you can see below to create a stored procedure CREATE keyword is used.

Modify (Alter) an existing Stored Procedure in SQL Server tutorial with example

Example

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

CREATE PROCEDURE GetEmployeeDetails

      @EmployeeID int = 0

AS

BEGIN

      SET NOCOUNT ON;

      SELECT FirstName, LastName, BirthDate, City, Country

      FROM Employees WHERE EmployeeID=@EmployeeID

END

GO

 

      

Alter or Modify a Stored Procedure

Below figure displays the syntax for alter a stored procedure. As you can see below to modify a stored procedure ALTER keyword is used rest all remains the same.

Modify (Alter) an existing Stored Procedure in SQL Server tutorial with example

Example

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

ALTER PROCEDURE GetEmployeeDetails

      @EmployeeID int = 0

AS

BEGIN

      SET NOCOUNT ON;

      SELECT FirstName, LastName, BirthDate, City, Country

      FROM Employees WHERE EmployeeID=@EmployeeID

END

GO