jawadxiv jawadxiv - 9 months ago 55
PHP Question

SQL Server 2008 R2 - Retrieving procedure input / output parameters

I am developing an application in PHP connected with SQL Server 2008 R2, my requirement is getting list of input / output parameters (METADATA) from procedure(s) and generating run time forms on the screen. I have around fifty scenarios e.g. get order details, get pending orders etc.

So instead of developing those 50 screens,I have decided to generate these forms on run time. Now I Googled my problem a bit and I came to know this feature is given in SQL Server 2012 by using sp_describe_first_result_set. Reference: link

Is there a way to achieve this in SQL Server 2008?

Answer Source

The next query returns a list of stored procedures and their parameters from the current database:

select pr.object_id [procedure_id]
, pr.name [procedure_name]
, p.parameter_id
, p.name [parameter_name]
, p.is_output
from sys.parameters p
join sys.procedures pr on p.object_id = pr.object_id
order by pr.object_id, p.parameter_id