日期:2014-05-18  浏览次数:20424 次

用户建立的储存过程个数怎么统计?
我要统计所有用户建立的,系统的储存过程,还有删除用户建立的,有没有sql语句可以实现

------解决方案--------------------
--系统存储过程
select name from sysobjects where xtype= 'P ' and category=2

--用户自定义存储过程
select name from sysobjects where xtype= 'P ' and category=0

--删除所有用户自定义存储过程
declare @sql varchar(8000)
set @sql= ' '
SELECT @sql=@sql+ 'drop proc '+NAME+char(13) FROM SYSOBJECTS
WHERE xtype= 'P ' and category=0
exec(@sql)