Hi,
T-SQL is really very limited language in terms of the things like SWITCH (or CASE). You would need to do
IF
begin
code here
end
ELSE
begin
IF other condition
begin
some code
end
END
In T-SQL you can use GOTO someLabel. I don't like this construct myself, but here I see it used a lot in the stored procedures.
>Hi,
>
>I am troubleshooting a fairly large stored procedure. And I think the issue is that some IF - ENDIF do not separate various conditions. Even though I use BEGIN and END.
>What is a good practice to separate various IF conditions in a stored procedure?
>
>TIA
>
>UPDATE. I also wanted to find out if there is a way to use ELSEIF in a stored procedure. I know you can do ELSE, but if I wanted to have multiple conditions, ELSEIF would be helpful. Or, is CASE - END the only way to have multiple conditions.
If it's not broken, fix it until it is.
My Blog