A stored procedure can return not only the query results, but also an identifier indicating the success or failure of the stored procedure. We can use return to return this identifier, whether a stored procedure provides a return value or not,ProgramA return value is returned. sqlserver automatically returns a 0 value when the stored procedure is completed by default.
Return values can be returned using return, for example: return 100
Note:The returned value must be an integer!
This return statement is similar to the Return Statement in functions of other languages. After the return statement is executed, it exits from the stored procedure insteadCode.
What does return mean? Actually, I seldom use it when writing a stored procedure. Every time I create a new stored procedure, the template will end with a return, and every time I delete it.
Consider this problem. If the returned value is 0 by default, it means there is no error, but this is not very good. It is clear that there is a problem in the stored procedure, but it still returns 0, we must clearly understand the meaning of the returned value so that we do not get an unexpected return value. Therefore, when the logic is not met, you can return an identifier to determine whether the execution of the stored procedure is correct.