Deleting a SQL Server stored procedure




By:
Overview

In addition to creating stored procedures there is also the need to delete stored procedures.  This topic shows you how you can delete stored procedures that are no longer needed.

Explanation

The syntax is very straightforward to drop a stored procedure, here are some examples.

Dropping Single Stored Procedure

To drop a single stored procedure you use the DROP PROCEDURE or DROP PROC command as follows.

DROP PROCEDURE dbo.uspGetAddress 
GO
-- or
DROP PROC dbo.uspGetAddress 
GO

Dropping Multiple Stored Procedures

To drop multiple stored procedures with one command you specify each procedure separated by a comma as shown below.

DROP PROCEDURE dbo.uspGetAddress, dbo.uspInsertAddress, dbo.uspDeleteAddress
GO
-- or
DROP PROC dbo.uspGetAddress, dbo.uspInsertAddress, dbo.uspDeleteAddress
GO

Last Update: 4/1/2009




More SQL Server Solutions











Post a comment or let the author know this tip helped.

All comments are reviewed, so stay on subject or we may delete your comment. Note: your email address is not published. Required fields are marked with an asterisk (*).

*Name
*Email
Email me updates

Signup for our newsletter

I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.





Friday, December 23, 2016 - 4:26:08 PM - Norbert Muth Back To Top

Hallo,

another tipp: make an example, how the drop or alter statement is executed only when the stored procedure exists.

And when the sp should be created, how it's done save; means: if not exists then create sp with a dummy statemnet and afterward an alter sp. So in any case you get the actual version without any errors.

best wishes

 

Norbert



download





get free sql tips

I agree by submitting my data to receive communications, account updates and/or special offers about SQL Server from MSSQLTips and/or its Sponsors. I have read the privacy statement and understand I may unsubscribe at any time.



Learn more about SQL Server tools