Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is better to return a single value in TSQL stored procedure: a RETURN or an OUTPUT?

I have a small stored procedure that needs to return a count of records (a single value). What is better to use? A RETURN to return the result or an OUTPUT parameter to return the result?

I'm using C# / .Net to 'talk' to SQL server.

like image 907
Kees C. Bakker Avatar asked Jan 23 '26 01:01

Kees C. Bakker


1 Answers

Use an output parameter.

It is less resource intensive to deal with a scalar parameter than a dataset via SELECT (or an OUTPUT clause etc) in the client

And RETURN is limited to int datatype. This doesn't matter here, but generally RETURN would be used for status and errors

like image 110
gbn Avatar answered Jan 25 '26 12:01

gbn