如何在SQL Server中检索存储过程的名称?

时间:2021-03-22 23:56:22

Is there any way to retrieve the names of the stored procedures by some SELECT from the system table or any system SP?

有没有办法从系统表或任何系统SP中通过某些SELECT检索存储过程的名称?

I need to retrieve all the stored procedure names with their signatures (if possible) or just names. I know how to do that in MySql, but similar queries don't work (of course, since all the system DBs named differently).

我需要检索所有存储过程名称及其签名(如果可能)或只是名称。我知道如何在MySql中执行此操作,但类似的查询不起作用(当然,因为所有系统DB的命名都不同)。

Thank you!

3 个解决方案

#1


This should do it:

这应该这样做:

SELECT  name
FROM    sys.objects
WHERE   type = 'P'

The ANSI way (which will work on both MySQL and MS SQL) is:

ANSI方式(适用于MySQL和MS SQL)是:

SELECT  ROUTINE_NAME
FROM    INFORMATION_SCHEMA.ROUTINES
WHERE   ROUTINE_TYPE = 'PROCEDURE'

#2


Not sure if this would work in MySQL but it works in MS SQL.

不确定这是否适用于MySQL,但它适用于MS SQL。

exec sp_stored_procedures

#3


SELECT * FROM sysobjects WHERE type=’p’

#1


This should do it:

这应该这样做:

SELECT  name
FROM    sys.objects
WHERE   type = 'P'

The ANSI way (which will work on both MySQL and MS SQL) is:

ANSI方式(适用于MySQL和MS SQL)是:

SELECT  ROUTINE_NAME
FROM    INFORMATION_SCHEMA.ROUTINES
WHERE   ROUTINE_TYPE = 'PROCEDURE'

#2


Not sure if this would work in MySQL but it works in MS SQL.

不确定这是否适用于MySQL,但它适用于MS SQL。

exec sp_stored_procedures

#3


SELECT * FROM sysobjects WHERE type=’p’