How to Delete All Stored Procedures From SQL Server Database

Sometimes we have to delete all the stored procedures from SQLServer. At that time we cant delete one by one.

So here is a way to delete all stored procedures from an SQL Server database

DECLARE @procedureName varchar(500)
DECLARE cur CURSOR
      FOR SELECT [name] FROM sys.objects WHERE type = 'p'
      OPEN cur

      FETCH NEXT FROM cur INTO @procedureName
      WHILE @@fetch_status = 0
      BEGIN
            EXEC('DROP PROCEDURE ' + @procedureName)
            FETCH NEXT FROM cur INTO @procedureName
      END
      CLOSE cur
      DEALLOCATE cur
Ebook Download
View all
Learn
View all