RETURN; before END
-
Hi all I have encountered a stored procedure template that we are supposed to use for our daily development work. The strange thing about this template (to me, at least) is that it has a RETURN statement just before the final END statement. Obviously if the proc is returning a value, this statement is necessary, but we are talking about a stored proc that returns no value. I do not understand why this convention exists, much less why someone would care to enforce it. It looks like it clutters the readability of the stored proc by appending code that does nothing. I don't recall seeing any C code like this: "void fx(void) { return; }", at least not on purpose. But I figure that this convention must have come from somewhere, and maybe at some point there were a perfectly valid and good reason for it. So my question is this: What good reason is there (if any) to have a RETURN; statement just prior to the final END statement in a stored proc that does not return a value? Here is an example:
CREATE PROC fx
AS
BEGIN
RETURN; -- Why is this here just before the END?
END
go -
Hi all I have encountered a stored procedure template that we are supposed to use for our daily development work. The strange thing about this template (to me, at least) is that it has a RETURN statement just before the final END statement. Obviously if the proc is returning a value, this statement is necessary, but we are talking about a stored proc that returns no value. I do not understand why this convention exists, much less why someone would care to enforce it. It looks like it clutters the readability of the stored proc by appending code that does nothing. I don't recall seeing any C code like this: "void fx(void) { return; }", at least not on purpose. But I figure that this convention must have come from somewhere, and maybe at some point there were a perfectly valid and good reason for it. So my question is this: What good reason is there (if any) to have a RETURN; statement just prior to the final END statement in a stored proc that does not return a value? Here is an example:
CREATE PROC fx
AS
BEGIN
RETURN; -- Why is this here just before the END?
END
go -
No reason. For TSQL the only thing I find odd with return is the need to put one after raiserror. Seems like raiserror itself would be sufficient to say stop.
-
Hi all I have encountered a stored procedure template that we are supposed to use for our daily development work. The strange thing about this template (to me, at least) is that it has a RETURN statement just before the final END statement. Obviously if the proc is returning a value, this statement is necessary, but we are talking about a stored proc that returns no value. I do not understand why this convention exists, much less why someone would care to enforce it. It looks like it clutters the readability of the stored proc by appending code that does nothing. I don't recall seeing any C code like this: "void fx(void) { return; }", at least not on purpose. But I figure that this convention must have come from somewhere, and maybe at some point there were a perfectly valid and good reason for it. So my question is this: What good reason is there (if any) to have a RETURN; statement just prior to the final END statement in a stored proc that does not return a value? Here is an example:
CREATE PROC fx
AS
BEGIN
RETURN; -- Why is this here just before the END?
END
goBecause that's where it belongs.
-
Because that's where it belongs.
I think I recognize a Fortran voice... :)
Luc Pattyn [My Articles] Nil Volentibus Arduum