Monday, April 18, 2011

How to drop all procedures

USE databasename
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