自定义函数,获取存储过程参数,可以先参考这篇《SQL Server INFORMATION_SCHEMA》https://www.cnblogs.com/insus/archive/2010/12/31/1923047.html
SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Insus.NET -- Create date: 2019-05-14 -- Update date: 2019-05-14 -- Description: 获取存储过程参数 -- ============================================= CREATE FUNCTION [dbo].[tvf_StoredProcedureParameter] ( @StoredProcedureName SYSNAME ) RETURNS @Parameters TABLE ( [Parameter Name] SYSNAME, [Data Type] SYSNAME, [Length] INT, [Scale] INT, [Direction] NVARCHAR(20) ) AS BEGIN INSERT INTO @Parameters SELECT PARAMETER_NAME,DATA_TYPE,ISNULL(CHARACTER_MAXIMUM_LENGTH, NUMERIC_PRECISION),NUMERIC_SCALE,PARAMETER_MODE FROM INFORMATION_SCHEMA.PARAMETERS WHERE SPECIFIC_SCHEMA = 'dbo' AND SPECIFIC_NAME = @StoredProcedureName ORDER BY ORDINAL_POSITION RETURN END GOSource Code
实例说明: