我目前正在记录我们数据库中的所有存储过程和函数。我已创建代码来收集过程的名称和参数,但是是否可以检索有关返回哪些列(如果有)的信息?
我知道有一个系统过程可以返回此信息,但是这是针对单个过程的,因为我对所有过程都需要它。
SELECT SCHEMA_NAME(SCHEMA_ID) AS [Schema],
SO.name AS [ObjectName],
SO.Type_Desc AS [ObjectType (UDF/SP)],
P.parameter_id AS [ParameterID],
P.name AS [ParameterName],
TYPE_NAME(P.user_type_id) AS [ParameterDataType],
P.max_length AS [ParameterMaxBytes],
P.is_output AS [IsOutPutParameter]
FROM sys.objects AS SO
INNER JOIN sys.parameters AS P
ON SO.OBJECT_ID = P.OBJECT_ID
WHERE SO.OBJECT_ID IN ( SELECT OBJECT_ID
FROM sys.objects
)
ORDER BY [Schema], SO.name, P.parameter_id
GO
有人知道这是否可能吗,如果可以的话,我该怎么做?
提前谢谢
答案 0 :(得分:0)
这是您要寻找的吗?
SELECT SCHEMA_NAME(SCHEMA_ID) AS [Schema],
so.object_id,
SO.name AS [ObjectName],
SO.Type_Desc AS [ObjectType (UDF/SP)],
P.parameter_id AS [ParameterID],
P.name AS [ParameterName],
TYPE_NAME(P.user_type_id) AS [ParameterDataType],
P.max_length AS [ParameterMaxBytes],
P.is_output AS [IsOutPutParameter],
c.name as [ColumnName],
TYPE_NAME(c.user_type_id) AS [ColumnDataType],
c.max_length AS [ColumnMaxBytes]
FROM sys.objects AS SO
INNER JOIN sys.parameters AS P
ON SO.OBJECT_ID = P.OBJECT_ID
LEFT JOIN sys.columns AS c
ON SO.OBJECT_ID = c.OBJECT_ID
WHERE SO.OBJECT_ID IN ( SELECT OBJECT_ID
FROM sys.objects
)
ORDER BY [Schema], SO.name, P.parameter_id
GO