日期:2014-05-17 浏览次数:20543 次
create function dbo.fn_air()
returns int
as
begin
declare @x int
if not exists(select 1 from 表1 where La='c')
begin
select @x=-1
return @x
end
if exists(select 1
from 表1 a
inner join 表2 b on a.Le=b.Le
where a.La='c' and a.Lc>b.Lcx)
begin
select @x=2
end
else
begin
select @x=-2
end
return @x
end
create function retValue()
returns int AS
begin
declare @cnt int
declare @ret int
select @cnt = count(*) from 表1 where la = 'c'
if @cnt = 0
select @ret = -1
else
select @ret = (case when lc > lcx then 2 else -2 end) from 表1 a inner join 表2 b on 表1.Le = 表2.Le where la = 'c'
return @ret
end
alter function dbo.fn_air()
returns int
as
begin
declare @x int
declare @s int
if exists(select 1 from a where La='c')
begin
select @x=Lc from a where La='c'
select @s=Lcx from b
if(@x>@s)
begin
select @x=2
end
else
begin
select @x=-2
end
end
else
begin
select @x=-1
end
return @x
end