2012-10-10 3 views
0

저장 프로 시저를 작성하고 반환 변수로 varchar (200) varibale을 가졌지 만 출력에서 ​​"varchar 값을 정수로 변환하는 동안 변환이 실패했습니다"라는 표시가 나타납니다 프로 시저는 int로 변환되지 않지만 im은 에러를 직면합니다.저장 프로 시저의 반환 값에 오류가 발생했습니다

alter proc rulename @mfid varchar(20) 
as 
declare @ACF2 varchar(200) 
begin 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where  [email protected]) > 0) 
begin 
set @ACF2='Apollo' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + 'GP' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'Tactical Comp' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'Unit Valuation' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where MFID=[email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'NPVS' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'Apollo Test' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'GP Test' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'Tactical Comp Test' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'Unit Valuation Test' 
end 
if((select count(distinct(Rulename)) as count1 from MainframeExtractsPLP where [email protected]) > 0) 
begin 
set @ACF2= @ACF2 + ',' + 'NPVS Test' 
end 
return @ACF2 
end 

답변

6

stored procedure is an integer의 반환 값입니다. output parameter instead을 사용해야합니다.

create procedure rulename 
    @mfid varchar(20), 
    @ACF2 varchar(200) output 
as 

-- Initialise param to empty string 
set @ACF2 = '' 

begin 
    if ... 
    begin 
     set @ACF2 = @ACF2 + '...' 
    end 
    . 
    . 
    . 
end