Unable to add constraint

Appears when a new constraint has failed on existing data or your constraint expression contains an error. Compare the ODBC error text that appears in the Save Incomplete dialog box with the error text shown below to determine the appropriate solution.

ODBC error text

[Microsoft][ODBC SQL Server Driver][SQL Server]Data exists in table '[table name]', database '[database name]', that violates CHECK constraint '[constraint name]' being added. ALTER command has been aborted.

[Microsoft][ODBC SQL Server Driver][SQL Server]Unable to create constraint. See previous errors.

Explanation

Existing data does not match the check constraint.

Action
See Also
Creating and Managing Database Diagrams Query Fundamentals
Database Diagrams Working with Database Objects
Filtering Rows with WHERE and HAVING  

 

ODBC error text

[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column '[column name]' specified in constraint definition.

[Microsoft][ODBC SQL Server Driver][SQL Server]Unable to create constraint. See previous errors.

Explanation
Action

Correct the expression and save the table.

ODBC error text

[Microsoft][ODBC SQL Server Driver][SQL Server]Line [line number]: Incorrect syntax near '[operator]'.

Explanation

The expression defined for the check constraint (in the Tables property page) or the default constraint (in the Default Value cell) is not valid Transact-SQL syntax. For example, the check constraint expression 'city equals Paris' was typed instead of 'city = Paris'.

Action

Correct the expression and save the table.

See Also
ALTER TABLE Database Diagrams
Constraints Filtering Rows with WHERE and HAVING
CREATE TABLE Query Fundamentals
Creating and Managing Database Diagrams Working with Database Objects

 

  


(c) 1988-98 Microsoft Corporation. All Rights Reserved.