Is there a way to use named parameters when getting the output parameters of a stored proc? Currently my knowledge of output parameters is very limited. It looks like I have to use them in order of their decleration in the stored proc. I.E if i did exec test @rich output,@bob output
the call would blow up. How can i have the order be arbitary? Thank you
create procedure test
@ID as INT output
,@mark as char(20) output
as
select @ID = 5,@mark='test'
go
declare @bob as int
declare @rich as char(20)
exec test @bob output, @rich output
select @bob,@rich
Best Answer
There is nothing special about OUTPUT parameters when it comes to "named parameters" or "ordinal parameters". In SQL Server this terminology this applies to the EXEC call and how you specify parameters there: not direction
This is ordinal
This is named
If you had a stored proc with parameters with defaults ...
.. then you need the DEFAULT keyword for ordinal parameters if you have subsequent mandatory parameters
For named parameters, it can be DEFAULT keyword or ignored because order is irrelevant
And the obligatory MSDN link