| title | sp_unbindefault (Transact-SQL) | Microsoft Docs | ||
|---|---|---|---|
| ms.custom | |||
| ms.date | 03/14/2017 | ||
| ms.prod | sql-non-specified | ||
| ms.reviewer | |||
| ms.suite | |||
| ms.technology |
|
||
| ms.tgt_pltfrm | |||
| ms.topic | language-reference | ||
| f1_keywords |
|
||
| dev_langs |
|
||
| helpviewer_keywords |
|
||
| ms.assetid | c96a6c5e-f3ca-4c1e-b64b-0d8ef6986af8 | ||
| caps.latest.revision | 38 | ||
| author | BYHAM | ||
| ms.author | rickbyh | ||
| manager | jhubbard |
[!INCLUDEtsql-appliesto-ss2008-xxxx-xxxx-xxx_md]
Unbinds, or removes, a default from a column or from an alias data type in the current database.
Important
[!INCLUDEssNoteDepNextDontUse] We recommend that you create default definitions by using the DEFAULT keyword in the ALTER TABLE or CREATE TABLE statements instead.
| Applies to: [!INCLUDEssNoVersion] ([!INCLUDEssKatmai] through current version). |
Transact-SQL Syntax Conventions
sp_unbindefault [ @objname = ] 'object_name'
[ , [ @futureonly = ] 'futureonly_flag' ]
[ @objname= ] 'object_name'
Is the name of the table and column or the alias data type from which the default is to be unbound. object_name is nvarchar(776), with no default. [!INCLUDEssNoVersion] attempts to resolve two-part identifiers to column names first, then to alias data types.
When unbinding a default from an alias data type, any columns of that data type that have the same default are also unbound. Columns of that data type with defaults bound directly to them are unaffected.
Note
object_name can contain brackets [] as delimited identifier characters. For more information, see Database Identifiers.
[ @futureonly= ] 'futureonly_flag'
Is used only when unbinding a default from an alias data type. futureonly_flag is varchar(15), with a default of NULL. When futureonly_flag is futureonly, existing columns of the data type do not lose the specified default.
0 (success) or 1 (failure)
To display the text of a default, execute sp_helptext with the name of the default as the parameter.
To unbind a default from a table column requires ALTER permission on the table. To unbind a default from an alias data type requires CONTROL permission on the type or ALTER permission on the schema to which the type belongs.
The following example unbinds the default from the hiredate column of an employees table.
EXEC sp_unbindefault 'employees.hiredate';
The following example unbinds the default from the alias data type ssn. It unbinds existing and future columns of that type.
EXEC sp_unbindefault 'ssn';
The following example unbinds future uses of the alias data type ssn without affecting existing ssn columns.
EXEC sp_unbindefault 'ssn', 'futureonly';
The following example shows using delimited identifiers in object_name parameter.
CREATE TABLE [t.3] (c1 int); -- Notice the period as part of the table
-- name.
CREATE DEFAULT default2 AS 0;
GO
EXEC sp_bindefault 'default2', '[t.3].c1' ;
-- The object contains two periods;
-- the first is part of the table name and the second
-- distinguishes the table name from the column name.
EXEC sp_unbindefault '[t.3].c1';
System Stored Procedures (Transact-SQL)
Database Engine Stored Procedures (Transact-SQL)
CREATE DEFAULT (Transact-SQL)
DROP DEFAULT (Transact-SQL)
sp_bindefault (Transact-SQL)
sp_helptext (Transact-SQL)
System Stored Procedures (Transact-SQL)