当前位置: 代码迷 >> Sql Server >> 怎么创建函数?为啥小弟我这段代码有异常
  详细解决方案

怎么创建函数?为啥小弟我这段代码有异常

热度:95   发布时间:2016-04-27 18:36:05.0
如何创建函数?为啥我这段代码有错误?
SQL code
create function hello2(@ix int,@iy int)return int isdeclare @temp int;if (@ix > @iy)begin @temp = @ixendelsebegin@temp = @iyendreturn @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
  相关解决方案