如题,我分4种情况,一直不行,如果不用If判断就可以通过
------解决方案--------------------
--try
create function fun(@flag int)
returns varchar(10)
as
begin
declare @re varchar(10)
if @flag=1
set @re= 'AA '
else if @flag=2
set @re= 'BB '
else
set @re= 'CC '
return @re
end
------解决方案--------------------
create function fun(@flag int)
returns @re table(i int)
as
begin
if @flag=1
insert into @re select 1
else if @flag=2
insert into @re select 2
else
insert into @re select 3
return
end