How do I get the return value from a stored procedure in a Microsoft SQL Server database?
There are two ways to obtain the return value of a stored procedure. Using the first way, you add an out-parameter (by-reference) to your output method and decorate it with the SqlReturnValue attribute. How you choose to name the parameter is irrelevant. The second way is to add a SqlParameter object with its Direction set to ParameterDirection.ReturnValue once a SqlCommand object has been created, initialized and returned by an input method. The latter approach avoids having to create an output method just to receive the return value. [Atif Aziz] During the initial design of DBMethods, I considered allowing output methods to have an integer return value that could be used to tunnel the return value of a stored procedure. The idea was finally dropped because there is no way to determine, using SQL Server metadata for example, whether a stored procedure has a return value or not. The safest assumption would therefore have been that all stored procedures return a value and this would for