自定义函数
--把年龄大于传过来的参数的数据的条数返回
create function FUN_GetUser(@UserAge int)
returns int
as
begin
declare @result int
set @result = (select count(1) from UserInfo where UserAge> @UserAge)
return @result
end
--执行函数
select dbo.FUN_GetUser(40)
表 值函数
create function FUN_UserInfo_GetUserInfo(@UserAge int)
returns table
as
return (select count(1) from UserInfo where UserAge> @UserAge)
--执行函数
select * from FUN_UserInfo_GetUserInfo(40)