A declarative default is a constraint defined as part of the table definition. Using declarative defaults is the preferred method for assigning default values to columns. You can use the
CREATE TABLE or
ALTER TABLE statement to create a default and assign it to a column. Declarative defaults are assigned to a single column and cannot be reused for other columns in the database. The following example shows the creation of a new column
namedCustomerType in the
SalesCustomer table followed by the creation of a new default on that column:
ALTER TABLE Sales.Customer ADD CustomerType CHAR(1)ALTER TABLE Sales.Customer ADD CONSTRAINT DF_Customer_CustomerType DEFAULT 'I' FOR CustomerType
It is important ...