27,582
社区成员




if exists(select Name from sysobjects where name='fnGetValue' and type='FN')
Drop Function fnGetValue
go
create Function fnGetValue (@a numeric(18,5),@b numeric(18,5),@aa varchar(20),@bb varchar(20)) returns varchar(20)
with encryption
as
begin
declare @cc varchar(20)
if @a>@b
return @aa
else
return @bb
return @cc
end
go
select dbo.fnGetValue(1,0,'a','b') --return a
select dbo.fnGetValue(0,1,'a','b') --return b
if exists(select Name from sysobjects where name='fnGetValue' and type='FN')
Drop Function fnGetValue
go
create Function fnGetValue (@b bit,@aa varchar(20),@bb varchar(20)) returns varchar(20)
with encryption
as
begin
declare @cc varchar(20)
if @b=1
return @aa
if @b=0
return @bb
return @cc
end
go
select dbo.fnGetValue(0,'a','b') --return b
select dbo.fnGetValue(1,'a','b') --return a