开发者_运维百科I know this is such a silly question but I tried every bracket I can think of to wrap the IF statement but it seems that none of them work.
For example:
IF(@item!=0){
//Do stub
RETURN // without the brakets , this return does not belong to if
}
//Do some stubs // and if the condition of the IF is false, this statement can't be reached
Thank you
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)
精彩评论