批量删除存储过程

DECLARE @STRING VARCHAR(8000)
WHILE EXISTS(SELECT * FROM sys.all_objects WHERE type = 'p' and name like 'Organ%')
BEGIN
 SELECT @STRING='DROP  PROCEDURE '+b.name+'.'+a.name  FROM   sys.all_objects a
 left join sys.schemas b on a.schema_id = b.schema_id
WHERE   a.type = 'P' AND a.name like 'Organ%'
 --SELECT @STRING
 EXEC(@STRING)
END

GO

SELECT * FROM sys.all_objects WHERE type = 'p' and name like 'Organ%'
select * from sys.schemas

 

其中'Organ%'指存储过程名称包含“Organ”关键字

转自http://www.cnblogs.com/wonechao/archive/2009/08/26/1554392.html

 

posted @ 2009-12-07 17:00  何翔华  阅读(256)  评论(0编辑  收藏  举报