| Lesson 7 | Deleting Stored Procedures |
| Objective | Describe how to delete a user-defined stored procedure. |
As applications evolve, some stored procedures become obsolete or must be removed to simplify maintenance and reduce technical debt. In SQL Server, deleting a user-defined stored procedure is a straightforward task, but it should be performed carefully because the action is permanent.
This lesson explains the supported methods for deleting stored procedures and highlights important considerations such as dependencies and permissions.
There are two common ways to delete a user-defined stored procedure:
To delete a stored procedure using SSMS:
SSMS provides a convenient interface, but it ultimately executes a
DROP PROCEDURE statement behind the scenes.
The preferred and most precise method is to use T-SQL. The basic syntax is shown below:
DROP PROCEDURE procedure_name;
You can delete multiple stored procedures in a single statement by listing them separated by commas:
DROP PROCEDURE procedure_one, procedure_two;
To delete a stored procedure named usp_DeleteEmployee, execute the following:
DROP PROCEDURE dbo.usp_DeleteEmployee;
Schema qualification (such as dbo) is recommended to ensure the correct
procedure is removed.
DROP PROCEDURE statement applies to user-defined stored procedures,
not system or extended stored procedures.
sql DROP PROCEDURE IF EXISTS dbo.usp_DeleteEmployee;
This prevents errors if the procedure doesn't exist and is considered best practice in modern SQL Server development.
In the next lesson, you will review how stored procedures relate to other database objects and how to manage them safely in production environments.