什么查询可以返回SQL Server数据库中所有存储过程的名称
如果查询可以排除系统存储过程,那将更有帮助。
什么查询可以返回SQL Server数据库中所有存储过程的名称
如果查询可以排除系统存储过程,那将更有帮助。
当前回答
下面将返回所选数据库中的所有过程
SELECT * FROM sys.procedures
其他回答
这也可以帮助列出除了系统过程之外的过程:
select * from sys.all_objects where type='p' and is_ms_shipped=0
这个,列出所有你想要的东西
在Sql Server 2005, 2008, 2012:
Use [YourDataBase]
EXEC sp_tables @table_type = "'PROCEDURE'"
EXEC sp_tables @table_type = "'TABLE'"
EXEC sp_tables @table_type = "'VIEW'"
OR
SELECT * FROM information_schema.tables
SELECT * FROM information_schema.VIEWS
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')
根据我的理解,“首选”方法是使用information_schema表:
select *
from information_schema.routines
where routine_type = 'PROCEDURE'
这将返回所有sp名称
Select *
FROM sys.procedures where [type] = 'P'
AND is_ms_shipped = 0
AND [name] not like 'sp[_]%diagram%'