DROP DEFAULT (Transact-SQL)

Removes one or more user-defined defaults from the current database.

Important

DROP DEFAULT will be removed in a future version of Microsoft SQL Server. Avoid using DROP DEFAULT in new development work, and plan to modify applications that currently use them. Instead, use default definitions that you can create by using the DEFAULT keyword of ALTER TABLE or CREATE TABLE. For more information, see Creating and Modifying DEFAULT Definitions.

Topic link iconTransact-SQL Syntax Conventions

Syntax

DROP DEFAULT { [ schema_name . ] default_name } [ ,...n ] [ ; ]

Arguments

  • schema_name
    Is the name of the schema to which the default belongs.
  • default_name
    Is the name of an existing default. To see a list of defaults that exist, execute sp_help. Defaults must comply with the rules foridentifiers. Specifying the default schema name is optional.

Remarks

Before dropping a default, unbind the default by executing sp_unbindefault if the default is currently bound to a column or an alias data type.

After a default is dropped from a column that allows for null values, NULL is inserted in that position when rows are added and no value is explicitly supplied. After a default is dropped from a NOT NULL column, an error message is returned when rows are added and no value is explicitly supplied. These rows are added later as part of the typical INSERT statement behavior.

Permissions

To execute DROP DEFAULT, at a minimum, a user must have ALTER permission on the schema to which the default belongs.

Examples

A. Dropping a default

If a default has not been bound to a column or to an alias data type, it can just be dropped using DROP DEFAULT. The following example removes the user-created default named datedflt.

USE AdventureWorks;
GO
IF EXISTS (SELECT name FROM sys.objects
         WHERE name = 'datedflt' 
            AND type = 'D')
   DROP DEFAULT datedflt
GO

B. Dropping a default that has been bound to a column

The following example unbinds the default associated with the EmergencyContactPhone column of the Employee table and then drops the default named phonedflt.

USE AdventureWorks;
GO
IF EXISTS (SELECT name FROM sys.objects
         WHERE name = 'phonedflt' 
            AND type = 'D')
   BEGIN 
      EXEC sp_unbindefault 'Person.Contact.Phone'
      DROP DEFAULT phonedflt
   END
GO

See Also

Reference

CREATE DEFAULT (Transact-SQL)
sp_helptext (Transact-SQL)
sp_help (Transact-SQL)
sp_unbindefault (Transact-SQL)

Help and Information

Getting SQL Server 2005 Assistance