2013-12-08 166 views
1

我正在學習存儲過程,這裏是我寫的代碼。但它給錯誤。SQL Server存儲過程中的錯誤

Error: Incorrect syntax near '@return'.

我的代碼:

create procedure test (@status varchar(50), @return varchar(50) output) 
as 
begin 
    if @status = 'running' 
     begin 
      @return = '1' 
     end 
    else 
     begin 
      @return = '2' 
     end 
end 

回答

1

它必須是

SET @收益率='1 '

其餘的都沒事

0

您需要實際使用SETSELECT分配值:

create procedure test (@status varchar(50), @return varchar(50) output) 
as 
begin 
    if @status = 'running' 
     SET @return = '1' 
    else 
     SET @return = '2' 
end