Friday, February 24, 2012

Is DEFAULT a constraint?

Hi,

I see the following in Books Online: CONSTRAINT--Is an optional keyword
indicating the beginning of a PRIMARY KEY, NOT NULL, UNIQUE, FOREIGN
KEY, or CHECK constraint definition...

But I have a table column defined as follows:

[MONTH] [decimal] (2, 0) NOT NULL CONSTRAINT
[DF__TBLNAME__MONTH__216361A7] DEFAULT (0)

My question: Is "DEFAULT" a constraint, or is it called something else?

Thanks,
EricEric Bragas (ericbragas@.yahoo.com) writes:

Quote:

Originally Posted by

I see the following in Books Online: CONSTRAINT--Is an optional keyword
indicating the beginning of a PRIMARY KEY, NOT NULL, UNIQUE, FOREIGN
KEY, or CHECK constraint definition...
>
But I have a table column defined as follows:
>
[MONTH] [decimal] (2, 0) NOT NULL CONSTRAINT
[DF__TBLNAME__MONTH__216361A7] DEFAULT (0)
>
My question: Is "DEFAULT" a constraint, or is it called something else?


There are actually two sorts of defaults: bound defaults and default
constraints. Bound defaults are deprecated, but are useful when you
bind them to types.

What you have above, is indeed a default constraints.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||Thank you for the clarification.

No comments:

Post a Comment