create Function FUN_GetUserCount(@id int)
returns int
as
begin
declare @result int
set @result=(select count(1) from userinfo where id>@id)
return @result
end
select dbo.FUN_GetUserCount(5)
--表值函数
create function FUN_UseInfo_GetUserInfo(@id int)
returns table
as
return (select * from userinfo where id>@id)
select * from FUN_UseInfo_GetUserInfo(5)