Bracket for IF statement in Stored Procedure
try begin and end instead
IF(@item!=0)
begin
/*Do stub*/
RETURN
/* without the brakets , this return does not belong to if */
end
Instead of RETURN
, you can also use ELSE
:
if @item != 0
begin
-- Do stub
end
else
begin
-- Do some stubs
-- and if the condition of the IF is false, this statement can't be reached
end
Plus:
- you don't need the brackets around the
IF
clause - you have to use
--
instead of//
for comments (see my example)