Delete all stored procedures at once in SQL Server database


In this post, we will about how to delete all stored procedures at once in SQL Server 2008 database. Also, you can check out my previous posts on:


– asp.net MVC 4 tutorial

– How to get Column names of a table in SQL Server 2008?

– Cookieless session in Asp.Net

Their different approach to delete all stored procedures in SQL Server 2008.

Approach-1:

SELECT ‘DROP PROCEDURE ‘ + p.NAME
FROM sys.procedures p

The above command will generate the DROP PROCEDURE statement like below:

And then you can copy those statements and put it in a new query window and run the commands.

Approach-2:

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



Hope it will work for you.

Check out Best Alternative to InfoPath -> Try Now

You May Also like the Following SharePoint Online Tutorials:

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

View all posts by Bijay Kumar →