2007-09-10

Granting EXECUTE to SQL Server User-defined Functions

In SQL Server, you can grant EXECUTE or REFERENCES to a scalar-valued user-defined function.  But if the function is table-valued, then only table permissions can be granted to it, not EXECUTE.

This consideration arose where I was programmatically granting EXECUTE to every user-defined function created by a script.  You can identify whether a function is scalar or table-valued with this query:

select objectproperty(id, N'IsTableFunction') from sysobjects where name=?