什么查询可以返回SQL Server数据库中所有存储过程的名称

如果查询可以排除系统存储过程,那将更有帮助。


当前回答

我编写了这个简单的tsql来列出所有存储过程的文本。请确保在字段中替换数据库名称。

use << database name >>
go

declare @aQuery nvarchar(1024);
declare @spName nvarchar(64);
declare allSP cursor for
select p.name  from sys.procedures p where p.type_desc = 'SQL_STORED_PROCEDURE' order by p.name;
open allSP;
fetch next from allSP into @spName;
while (@@FETCH_STATUS = 0)
begin
    set @aQuery = 'sp_helptext [Extract.' + @spName + ']';
    exec sp_executesql @aQuery;
    fetch next from allSP;
end;
close allSP;
deallocate allSP;

其他回答

select *  
  from dbo.sysobjects
 where xtype = 'P'
   and status > 0

选择“所有存储过程和视图”

select name,type,type_desc
from sys.objects
where type in ('V','P')
order by name,type

在SQL server中选择存储过程列表。更多信息请参考这里: https://coderrooms.blogspot.com/2017/06/select-list-of-stored-procedure-in-sql.html

select * from DatabaseName.INFORMATION_SCHEMA.ROUTINES where routine_type = 'PROCEDURE'

select * from DatabaseName.INFORMATION_SCHEMA.ROUTINES where routine_type ='procedure' and left(ROUTINE_NAME,3) not in('sp_', 'xp_', 'ms_')


   SELECT name, type   FROM dbo.sysobjects
 WHERE (type = 'P')

试试这个codeplex链接,这个实用程序帮助本地化sql数据库中的所有存储过程。

https://exportmssqlproc.codeplex.com/