Skip to content

Instantly share code, notes, and snippets.

@kad1r
Created April 16, 2013 21:22
Show Gist options
  • Save kad1r/5399758 to your computer and use it in GitHub Desktop.
Save kad1r/5399758 to your computer and use it in GitHub Desktop.
Drop all stored procedures in database
-- first drop function
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
begin
exec('drop procedure ' + @procName)
fetch next from cur into @procName
end
close cur
deallocate cur
-- second drop function
-- this function generates list of DROP PROCEDURE statements
-- copy the results, open new query then paste and run.
SELECT 'DROP PROCEDURE ' + p.NAME
FROM sys.procedures p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment