获取存储过程参数

自定义函数,获取存储过程参数,可以先参考这篇《SQL Server INFORMATION_SCHEMAhttps://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
GO
Source Code

 

实例说明:

 

posted @ 2019-05-14 14:44  Insus.NET  阅读(835)  评论(1编辑  收藏  举报