批量删除存储过程脚本

--sql2000
DECLARE @STRING VARCHAR(8000)
WHILE EXISTS(SELECT * FROM SYSOBJECTS WHERE xtype = 'p' and name like 'PRC%'
AND status >=0 AND name <> 'PRC_TASK_LIST_SELALL')
BEGIN
 SELECT @STRING='DROP  PROCEDURE '+name  FROM   SYSOBJECTS    WHERE   xtype = 'P' AND STATUS>=0 and name like 'PRC%' and name <> 'PRC_TASK_LIST_SELALL'
 --SELECT @STRING
 EXEC(@STRING)
END

GO

 

--sql2005
DECLARE @STRING VARCHAR(8000)
WHILE EXISTS(SELECT * FROM sys.all_objects WHERE type = 'p' and name like 'PRC%')
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 'PRC%'
 --SELECT @STRING
 EXEC(@STRING)
END

GO

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

 


 

你可能感兴趣的:(存储过程)