Reputation: 15441
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
Upvotes: 1
Views: 2527
Reputation: 1534
I've always returned the number of records modified but it isn't required.
Upvotes: 0
Reputation: 21198
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
Upvotes: 2
Reputation: 382726
Not necessary. It just indicates that you have finished working on that particular stored procedure. Return statement is usually good in conditions
Upvotes: 1
Reputation: 46425
I think you answered your own question:
I have always never put a return statement
A return statement is not required.
Upvotes: 5
Reputation: 351526
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.
Upvotes: 8