What is the syntax to drop a Stored Procedure in SQL Server 2000?

Viewed 99503

Simple question, as the title suggests:

What is the syntax to drop a Stored Procedure (SP) in SQL Server 2000, by first checking that the SP exists?

Please provide the full code.

6 Answers

Not for SQL Server 2000, but starting with SQL Server 2016, you can use the IF EXISTS syntax:

DROP PROCEDURE IF EXISTS [sp_ProcName]

You can do the following if you want to remove multiple Procedures. NB: This syntax works on SQL Server 2016 and later

USE [Database_name]
GO

BEGIN 
DROP PROCEDURE IF EXISTS    'my_procedure1',
                            'my_procedure2',
                            'my_procedure3',
                            'my_procedure4',
                            'my_procedure5',
END
    
Related