Permissions for User-Defined Functions

SQL Server Setup Help

SQL Server Setup Help

Permissions for User-Defined Functions

Functions are subroutines made up of one or more Transact-SQL statements that can be used to encapsulate code for reuse. Microsoft® SQL Server™ 2000 allows users to create their own user-defined functions.

User-defined functions are managed through the following statements:

  • CREATE FUNCTION, which creates a user-defined function.

  • ALTER FUNCTION, which modifies user-defined functions.

  • DROP FUNCTION, which drops user-defined functions.

Each fully qualified user-defined function name (database_name.owner_name.function_name) must be unique.

You must have been granted CREATE FUNCTION permissions to create, alter, or drop user-defined functions. Users other than the owner must be granted EXECUTE permission on a function (if the function is scalar-valued) before they can use it in a Transact-SQL statement. If the function is table-valued, the user must have SELECT permissions on the function before referencing it. If a CREATE TABLE or ALTER TABLE statement references a user-defined function in a CHECK constraint, a DEFAULT clause, or a computed column, the table owner must also own the function. If the function is being schema-bound, you must have REFERENCE permission on tables, views, and functions referenced by the function.

REFERENCE permissions can be granted through the GRANT statement to views and user-defined functions in addition to tables.

See Also

User-Defined Functions