日期:2014-05-18  浏览次数:20492 次

如何创建函数?为啥我这段代码有错误?
SQL code

create function hello2(@ix int,@iy int)
return int 
is
declare @temp int;
if (@ix > @iy)
begin 
@temp = @ix
end
else
begin
@temp = @iy
end
return @temp


------解决方案--------------------
探讨

引用:

create function hello2(@ix int,@iy int)
return int
is
declare @temp int;
if (@ix > @iy)
begin
set @temp = @ix
end
else
begin
set @temp = @iy
end
return @temp


还是……

------解决方案--------------------
create function hello2(@ix int,@iy int)
returns int
as
begindeclare @temp int;
if (@ix > @iy)
begin
set @temp = @ix
end
else
begin
set @temp = @iy
end
return @temp
end