批量删除存储过程的存储过程

CREATE   PROCEDURE   dropProcedure
AS
declare cur cursor
read_only
for select name from sysobjects where xtype='p' and name like 'drop%'

declare @name varchar(40),@sql varchar(1000)
open cur

fetch next from cur into @name
while (@@fetch_status =0)
begin
set @sql ='drop Procedure ' + @name
exec (@sql)

fetch next from cur into @name
end

close cur
deallocate cur
go
dropProcedure

2. 

DECLARE Del_Cursor CURSOR
FOR
SELECT 'DROP PROCEDURE ' + name from dbo.sysobjects WHERE OBJECTPROPERTY(id, N'IsProcedure') = 1 AND name not like 'USP_Blog%'
OPEN Del_Cursor
DECLARE @curname sysname
FETCH NEXT FROM Del_Cursor into @curname
WHILE(@@fetch_status=0)
  BEGIN
  EXEC(@curname)
  FETCH NEXT FROM Del_Cursor into @curname
  END
CLOSE Del_Cursor
DEALLOCATE Del_Cursor

posted @ 2010-06-29 23:54  lixq0203  阅读(304)  评论(0编辑  收藏  举报