1

I had a sproc that executed a select statement, result was a single column and single row that I assigned to an output parameter.

Now the sproc has to grow to return two columns from a single row result set.

What is the cleanest way to keep the single select (just making it return two columns instead of one) and have two row values assigned to seperate (output) variables?

Thanks.

2 Answers 2

1

You can just declare 2 output parameters and assign to both from the same select

select @foo = foo, @bar=bar ...

Sign up to request clarification or add additional context in comments.

Comments

1

If you are looking for a return value that isn't scalar (i.e. a set of data), then you won't really be able to use a stored procedure. A table variable can be READONLY in a stored procedure.

I'd recommend converting your stored procedure logic to a Table-Valued Function. This will be fine as long as you aren't doing any DML statements inside the function. But as per your description, it seems like it's just a SELECT.

Also, the benefit of a function is it can be queried inline.

Comments

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.