Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

CHECK Constraint

Can this be done according to MSDN yes but I must have the wrong wording.

Summary
I want a check constraint on a column that is Greater then or equal to the
sum of two other columns.

Table Script

CREATE TABLE dbo.TableA (

col_ColumnA int NOT NULL CONSTRAINT df_TableA_col_ColumnA DEFAULT 6, CONSTRAINT
cc_TableA_col_ColumnA CHECK (col_ColumnA >= (col_ColumnC + col_ColumnD)),
col_ColumnB int NOT NULL CONSTRAINT df_TableA_col_ColumnB DEFAULT 12,
col_ColumnC int NOT NULL CONSTRAINT df_TableA_col_ColumnC DEFAULT 0,
col_ColumnD int NOT NULL CONSTRAINT df_TableA_col_ColumnD DEFAULT 0

)

Thank you
Scott
[685 byte] By [Scott] at [2007-11-9 21:07:31]