MSSQL – Drop all SP and Table on a Database

Execute this with Precaution

USE YourDataBaseName
declare @procName varchar(500)
declare cur cursor
for select [name] from sys.objects where type = ‘p’
open cur
fetch next from cur into @procName
while @@fetch_status = 0
exec(‘drop procedure [‘ + @procName+’]’)
fetch next from cur into @procName
close cur
deallocate cur
EXEC sp_MSforeachtable @command1 = “DROP TABLE [?]”



Author: Thomie Jose San Agustin

He is a Microsoft Certified Professional whom develop different website using ASP .NET MVC and PHP. He can also create systems out of C#. A Magna Cum Laude of Adamson University whom started a Freelance company named i-CT Combinatorics Technology with his friend Calbin Montalban. He accepts both Website and System development and even can help now his colleagues in generating their logic and research.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.