一个简单的sel server 函数的自定义

创建自定义函数:
use 数据库名
go
create function 函数名
(@pno int)
returns int
as
begin
  declare @a int
   if not exists(select * from person where pno=@pno)
      set @a=-1
   else
      set @a=1
  return @a
end

调用函数:
use 数据库名
go
select dbo.函数名(13250)

原文地址:https://www.cnblogs.com/tomahawk/p/4013961.html