Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
DROP FUNCTION (Transact-SQL)
Collapse the table of content
Expand the table of content

DROP FUNCTION (Transact-SQL)

Removes one or more user-defined functions from the current database. User-defined functions are created by using CREATE FUNCTION and modified by using ALTER FUNCTION.

Topic link icon Transact-SQL Syntax Conventions

DROP FUNCTION { [ schema_name. ] function_name } [ ,...n ] 

schema_name

Is the name of the schema to which the user-defined function belongs.

function_name

Is the name of the user-defined function or functions to be removed. Specifying the schema name is optional. The server name and database name cannot be specified.

DROP FUNCTION will fail if there are Transact-SQL functions or views in the database that reference this function and were created by using SCHEMABINDING, or if there are computed columns, CHECK constraints, or DEFAULT constraints that reference the function.

DROP FUNCTION will fail if there are computed columns that reference this function and have been indexed.

To execute DROP FUNCTION, at a minimum, a user must have ALTER permission on the schema to which the function belongs, or CONTROL permission on the function.

A. Dropping a function

The following example drops the fn_SalesByStore user-defined function from the Sales schema in the AdventureWorks sample database. To create this function, see Example B in CREATE FUNCTION (Transact-SQL).

USE AdventureWorks2012;
GO
IF OBJECT_ID (N'Sales.fn_SalesByStore', N'IF') IS NOT NULL
    DROP FUNCTION Sales.fn_SalesByStore;
GO

Community Additions

ADD
Show:
© 2015 Microsoft