删除表中存储过程和视图


--视图
declare   @sql   varchar(8000) set   @sql= ''select   @sql=@sql+ ', '+name   from   sysobjects where   type= 'V '   and   name   not   in( 'syssegments ',   'sysconstraints ') set   @sql= 'drop   view   '+stuff(@sql,   1,   1,   ' ') exec(@sql)

Go
--删除存储过程
DECLARE @STRING VARCHAR(8000)
WHILE EXISTS(SELECT NAME FROM SYSOBJECTS WHERE TYPE='P' AND STATUS>=0)
BEGIN
SELECT TOP 1 @STRING='DROP PROCEDURE '+ NAME FROM SYSOBJECTS WHERE TYPE = 'P' AND STATUS>=0
--SELECT @STRING
exec(@STRING)
END
GO

posted @ 2011-04-11 20:08  HTL  阅读(364)  评论(0编辑  收藏  举报
htl