Wednesday, March 16, 2011

Bulk Delete/Drop Stored Procedures from Database

I had to recently clean up a database and get rid of all the custom stored procedures in it. Unfortunately, there were more than a 100 SP's in the database and it was not possible to delete them one by one. Fortunately, I found a great line of code here (http://forums.asp.net/t/1340617.aspx) that will give me a list of all the stored procedures with the 'Drop' command. I just had to copy the results from the below query, paste and execute them in the query editor window.

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

No comments:

Post a Comment