0

Here I have a sql script which retrieves all stored procedures and it's parameters.

select * 
from sys.parameters 
inner join sys.procedures on parameters.object_id = procedures.object_id 
inner join sys.types on parameters.system_type_id = types.system_type_id 
                     and parameters.user_type_id = types.user_type_id
--where procedures.name = 'STORED_PROC_NAME'

What I want to do is to be able to grab the stored procedures output parameters this way if at all possible.

If someone could point me to where in the sys catalog views I can find this information, it would be appreciated! Thanks!

1 Answer 1

1

The column is_output in sys.parameters is 1, when it is an output parameter.

is_output     bit     1 = Parameter is OUTPUT or RETURN; otherwise, 0.

From: https://learn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-parameters-transact-sql?view=sql-server-2017

So change your query to:

select *
       from sys.parameters 
            inner join sys.procedures
                       on parameters.object_id = procedures.object_id 
            inner join sys.types
                       on parameters.system_type_id = types.system_type_id
                       and parameters.user_type_id = types.user_type_id
       where parameters.is_output = 1;
Sign up to request clarification or add additional context in comments.

2 Comments

Ah! So simple and it was right there in front of me :p Thanks! Issue resolved.
@user2292759 Perhaps you can accept the reply as the answer?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.