I know that have many decisions about it.
Yet. If I have procedure then in many cases, I want to select a result and exit the procedure.
It good to use GOTO statement, or have a better way (not classic if...else)
Example:
create procedure MyProc @Parm int
as
declare @Result nvarchar(50)
set @Result = 'OK'
if @Parm = 1 begin
set @Result = 'Error Example 1'
goto ExitProc;
end
if @Parm = 2 begin
set @Result = 'Error Example 2'
goto ExitProc;
end
if @Parm = 3 begin
set @Result = 'Error Example 3'
goto ExitProc;
end
ect...
ExitProc:
select @Result as Result, 100 as P2
from Table1