简体   繁体   中英

Are return statements required for stored procedures?

If you have a stored procedure that deletes record in a table, do you have to put a return statement and why?

I have always never put a return statement, but I just saw a snippet that has a return statement.

Sample:

DELETE 
FROM TableName
WHERE TableId = @Id

RETURN

No, an empty return statement is optional. The only time it would be required is if you needed to return a value from the procedure, then you would need to either create a result set with a select statement or return a value.

In cases like yours the return statement is purely optional.

I think you answered your own question:

I have always never put a return statement

A return statement is not required.

No, Return statement is not at all compulsary. if you need to get some value whether it is a datatable or any datatype then only you have to use return keyword.

Return can be used at the time of calling a stored procedure from another stored procedure

Not necessary. It just indicates that you have finished working on that particular stored procedure. Return statement is usually good in conditions

我总是返回修改过的记录数,但这不是必需的。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM