How can I bulk delete stored procedures in MS SQL?

I accidentally added several stored procedures to the wrong schema. I'd like to be able to delete them all from Microsoft SQL Server Management Studio without having to right click delete each one.

Related tags: MSSQL

Credit: Original Poster

declare @name varchar(max)

declare dcursor CURSOR
    FOR SELECT name AS procedure_name
    FROM sys.procedures
    WHERE SCHEMA_NAME(schema_id) = 'db_owner'
open dcursor
while @@FETCH_STATUS = 0
BEGIN
    fetch next FROM dcursor
    INTO @name

    declare @sql nvarchar(max)
    SELECT @sql = N'drop procedure db_owner.' + @name
    exec(@sql)
END
CLOSE dcursor
DEALLOCATE dcursor

Rating: 1

Propose a different solution...