Last active
August 29, 2015 14:03
-
-
Save kdarty/eb2e80579b753711f7b4 to your computer and use it in GitHub Desktop.
Drop All Stored Procedures for SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/******************************************************/ | |
/** Description:Deletes all Stored Procedures in the **/ | |
/** given Database. **/ | |
/** **/ | |
/** WARNING: This can be very Dangerous. Verify **/ | |
/** your current Database connection **/ | |
/** before use. It is recommended to **/ | |
/** enter the Target Database in the **/ | |
/** USE clause. **/ | |
/** **/ | |
/** Source: http://bit.ly/DropAllProcedures **/ | |
/******************************************************/ | |
USE [EnterDatabaseNameForSafety] | |
DECLARE @procName VARCHAR(500) | |
DECLARE procCursor CURSOR FOR | |
SELECT [Name] | |
FROM sys.objects | |
WHERE Type = 'p' | |
OPEN procCursor | |
FETCH NEXT FROM procCursor INTO @procName | |
WHILE @@fetch_status = 0 | |
BEGIN | |
EXEC('drop procedure ' + @procName) | |
FETCH NEXT FROM procCursor INTO @procName | |
END | |
CLOSE procCursor | |
DEALLOCATE procCursor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment