查询以列出所有存储过程 [英] Query to list all stored procedures
本文介绍了查询以列出所有存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
什么查询可以返回 SQL Server 数据库中所有存储过程的名称
What query can return the names of all the stored procedures in a SQL Server database
如果查询可以排除系统存储过程,那就更有帮助了.
If the query could exclude system stored procedures, that would be even more helpful.
推荐答案
正如 Mike 所说,最好的方法是使用 information_schema
.只要不在master数据库中,就不会返回系统存储过程.
As Mike stated, the best way is to use information_schema
. As long as you're not in the master database, system stored procedures won't be returned.
SELECT *
FROM DatabaseName.INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
如果由于某种原因您在 master 数据库中有非系统存储过程,您可以使用查询(这将过滤掉 MOST 系统存储过程):
If for some reason you had non-system stored procedures in the master database, you could use the query (this will filter out MOST system stored procedures):
SELECT *
FROM [master].INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
AND LEFT(ROUTINE_NAME, 3) NOT IN ('sp_', 'xp_', 'ms_')
这篇关于查询以列出所有存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文