When a function is initially created, the only user who has permission to execute or query the function is the user who created it. To allow other users to execute a scalar function, you need to grant
EXECUTE permission on the function to the appropriate user(s), group(s), or role(s). For a table-valued function, you need to grant
SELECT permission to the user(s), group(s), or role(s) that will need to reference it. The following example grants
EXECUTE permission on the
getonlydate() function to everyone and
SELECT permission on the
AveragePriceByType function to the database user
GRANT EXECUTE on dbo.getonlydate to publicGRANT SELECT on [HumanResources].[AveragePayRatebyJobTitle]to ...