2011-08-12 4 views
4

나는이 바보 같은 질문을 알고 있지만 IF 문을 래핑 할 생각할 수있는 모든 괄호를 시도했지만 그것은 작동하지 것 같습니다. 예를 들어브래킷에 대한 저장 프로 시저

:

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 

감사합니다

답변

11

시작과 RETURN하는 대신 대신

IF(@item!=0) 
begin 
/*Do stub*/ 
RETURN 
/* without the brakets , this return does not belong to if */ 
end 
3

을 종료하려고, 당신은 또한 사용할 수 있습니다 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 

플러스 :

  • 당신이 IF 절 주위에 괄호가 필요하지 않습니다
  • 당신은
(내 예 참조) 의견 -- 대신 //을 사용해야합니다