SqlServer 获取 存储过程 的 参数信息

SELECT b.name SchemaName, sp.object_Id as FunctionId, sp.name as FunctionName,
isnull(param.name,'')as ParamName,isnull(usrt.name,'') AS [DataType],
ISNULL(baset.name, '') AS [SystemType], CAST(CASE when baset.name is null then 0  WHEN baset.name IN ('nchar', 'nvarchar') AND param.max_length <> -1 THEN param.max_length/2 ELSE param.max_length END AS int) AS [Length],
'' as ParamReamrk,isnull(parameter_id,0) as SortId,
param.Is_Output
FROM sys.objects AS sp  INNER JOIN sys.schemas b ON sp.schema_id = b.schema_id
left outer JOIN sys.all_parameters param ON param.object_id=sp.object_Id
LEFT OUTER JOIN sys.types AS usrt ON usrt.user_type_id = param.user_type_id
LEFT OUTER JOIN sys.types AS baset ON (baset.user_type_id = param.system_type_id and baset.user_type_id = baset.system_type_id) or ((baset.system_type_id = param.system_type_id) and (baset.user_type_id = param.user_type_id) and (baset.is_user_defined = 0) and (baset.is_assembly_type = 1)) 
LEFT OUTER JOIN sys.extended_properties E ON sp.object_id = E.major_id
Where sp.TYPE in ('FN', 'IF', 'TF','P')  AND ISNULL(sp.is_ms_shipped, 0) = 0 AND ISNULL(E.name, '') <> 'microsoft_database_tools_support'
and sp.name ='{StoredProcedure}'
orDER BY sp.name,param.parameter_id ASC

查询结果如下图:
SqlServer 获取 存储过程 的 参数信息_第1张图片

你可能感兴趣的:([,07,],SQL,Server)