DROP FUNCTION (Transact-SQL)
Applies To: SQL Server 2014, SQL Server 2016 Preview
Topic Status: Some information in this topic is preview and subject to change in future releases. Preview information describes new features or changes to existing features in Microsoft SQL Server 2016 Community Technology Preview 2 (CTP2).
The DROP function supports natively compiled, scalar user-defined functions. For more information, see Scalar User-Defined Functions for In-Memory OLTP.
Applies to: SQL Server (SQL Server 2008 through current version), Azure SQL Database.
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.
A. Dropping a function
The following example drops the fn_SalesByStore user-defined function from the Sales schema in the AdventureWorks2012 sample database. To create this function, see Example B in CREATE FUNCTION (Transact-SQL).
IF OBJECT_ID (N'Sales.fn_SalesByStore', N'IF') IS NOT NULL DROP FUNCTION Sales.fn_SalesByStore; GO