Thursday, January 9, 2020

Getting the list of parameters from a stored procedure in SQL


use the INFORMATION_SCHEMA.parameters view
 
SELECT parameter_name, ordinal_position,parameter_mode,data_type
FROM INFORMATION_SCHEMA.parameters
WHERE SPECIFIC_NAME = 'USP_TableList'


use sys.parameters and join that with sys.types

SELECT s.name AS parameter_name,
   parameter_id AS ordinal_position,
   CASE is_output WHEN 0 THEN 'IN' ELSE 'INOUT' END Parameter_Mode,
   t.name AS data_type
FROM sys.parameters s
JOIN sys.types t ON s.system_type_id = t.user_type_id
WHERE object_id = object_id('USP_TableList')

Here is the output



parameter_nameordinal_positionparameter_modedata_type
@id1INint
@Date2INdate
@char3INOUTchar

No comments:

Post a Comment

Mixed Content: The page at xxx was loaded over HTTPS, but requested an insecure

 Mixed Content: The page at ' https ://www.test.com/signup.aspx' was loaded over HTTPS, but requested an insecure script ' http ...