Wednesday, June 17, 2009

Delete all Procedure of Database

Sometimes you need to delete all the stored procedures in database. instead of deleting SPs one by one.
This query generates the drop statements for all the stored procedures.

First, right - click on the query pane and choose "Results to text".

Next, execute this script:

Select 'Drop Procedure ' + name from sys.procedures Where [type] = 'P' and is_ms_shipped = 0 and [name] not like 'sp[_]%diagram%'

What you'll get is a nice list of "Drop Procedure" statements that you can paste into the query editor window and execute.