什么查询可以返回SQL Server数据库中所有存储过程的名称
如果查询可以排除系统存储过程,那将更有帮助。
什么查询可以返回SQL Server数据库中所有存储过程的名称
如果查询可以排除系统存储过程,那将更有帮助。
当前回答
下面将返回所选数据库中的所有过程
SELECT * FROM sys.procedures
其他回答
select *
from dbo.sysobjects
where xtype = 'P'
and status > 0
这将只给出存储过程的名称。
select specific_name
from information_schema.routines
where routine_type = 'PROCEDURE';
这将显示所有的存储过程和代码:
select sch.name As [Schema], obj.name AS [Stored Procedure], code.definition AS [Code] from sys.objects as obj
join sys.sql_modules as code on code.object_id = obj.object_id
join sys.schemas as sch on sch.schema_id = obj.schema_id
where obj.type = 'P'
如果你使用的是SQL Server 2005,下面的操作可以正常工作:
select *
from sys.procedures
where is_ms_shipped = 0
exec sp_stored_procedures; Docs.Microsoft.com
很容易记住。