Query to find Number of Parameters in a Stored Pro

2019-01-26 17:13发布

问题:

Well, if i want to find parameter count of any stored procedure or function inside SQL SERVER, what is the correct way to do it.

Your help would be appreciated. thanks.

回答1:

Try the following query to get a list of all parameters for a stored procedure. Change the select to a COUNT(*) if you just want the number of parameters.

SELECT 
    p.name AS Parameter,        
    t.name AS [Type]
FROM sys.procedures sp
JOIN sys.parameters p 
    ON sp.object_id = p.object_id
JOIN sys.types t
    ON p.system_type_id = t.system_type_id
WHERE sp.name = '<name>'


回答2:

INFORMATION_SCHEMA.PARAMETERS should be all you need...

SELECT  *
FROM    INFORMATION_SCHEMA.PARAMETERS


回答3:

SELECT  *
FROM    INFORMATION_SCHEMA.PARAMETERS where SPECIFIC_NAME = 'YourProcedureName'