--创建函数
if exists(select 1 from sysobjects where id=object_id('GetMax') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetMax]  --如果在系统中存在该函数,则删除
go
create function GetMax(@x int,@y int)
returns int
--with encryption --加上这句表示加密
as
begin
declare @t int
if(@x>@y)
set @t=@x
else
set @t=@y
return @t
end
go

select dbo.GetMax(6.9,3.3) --调用时 不是直接GetMax 而是dbo.GetMax
--6
go
sp_helptext getmax   --查看该函数的详细信息(加密后无法查看)
go
drop function dbo.getmax --删除该函数
go