How To : Drop all stored procedures from a database

Ever faced such a condition where you need to remove all stored procedures from your Database?
If you have to do the same, what will you do?  I am sure you will Google :)

I have got a link at MattBerther where you can find a script that helps you to remove all stored procedures from selected database.
Here is the copy of that script:

USE myDatabase
GO

declare @procName sysname

declare someCursor cursor for
    select name from sysobjects where type = 'P' and objectproperty(id, 
'IsMSShipped') = 0

open someCursor
fetch next from someCursor into @procName
while @@FETCH_STATUS = 0
begin
    exec('drop proc ' + @procName)
    fetch next from someCursor into @procName
end

close someCursor
deallocate someCursor
go

No comments:

Post a Comment