Check Object (SQL-DMO)

The Check object represents the attributes of a single Microsoft® SQL Server™ integrity constraint.

Remarks

A SQL Server integrity constraint can be defined as part of a CREATE TABLE statement or can be added to, or removed from, a table as part of an ALTER TABLE statement.

With the Check object, you can:

The Name property represents a constraint name. It is character data and must be unique within a SQL Server database.

To create a SQL Server integrity constraint

  1. Create a Check object.
  2. Set the Name property.
  3. Set the Text property to define the constraint.

    Adding the Check object to its containing collection generates the appropriate CREATE statement. Specify only the integrity test condition in the Text property.

  4. Set the ExcludeReplication property.
  5. Add the Check object to the Checks collection of a Table object.

To remove a SQL Server integrity constraint

  1. Get the appropriate Table object from the Tables collection of a Database object.
  2. Use the BeginAlter method of the Table object to mark the start of alterations on the SQL Server table.
  3. Get the desired Check object from the Checks collection of the Table object.
  4. Use the Remove method of the Check object to drop its integrity constraint from the SQL Server table.
  5. Use the DoAlter method of the Table object to submit the change to the SQL Server.
Methods
Remove Method (Objects) Script Method

Properties
Checked Property Name Property
ExcludeReplication Property Text Property

See Also
ALTER TABLE CREATE TABLE

  


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