Condividi tramite


Checks Collection

Questa funzionalità verrà rimossa in una delle prossime versioni di Microsoft SQL Server. Evitare di utilizzare questa funzionalità in un nuovo progetto di sviluppo e prevedere interventi di modifica nelle applicazioni in cui è attualmente implementata.

The Checks collection contains Check objects that expose Microsoft SQL Server integrity constraints defined on the columns of a table.

Modello di oggetti SQL-DMO in cui è visualizzato l'oggetto corrente

Methods

Add Method

Remove Method (Collections)

Refresh Method

 

Osservazioni

With the Checks collection, you can:

  • Define an integrity constraint on a SQL Server column.
  • Remove an existing constraint from a SQL Server column.

SQL Server integrity constraints can be defined as part of a CREATE TABLE or ALTER TABLE statement.

When creating a SQL Server table using the Table object, an empty Checks collection is created as part of the Table object creation. Adding Check objects to the Checks collection adds constraint definition text to the CREATE TABLE statement generated when the Table object is added to the Tables collection of a Database object.

If a Table object references an existing SQL Server table, changes to the Checks collection generate ALTER TABLE statements.

For more information about creating integrity constraints, see Check Object.

To remove a CHECK constraint

  1. Get the desired Table object from the Tables collection of a Database object.

  2. Use the BeginAlter method of the Table object to mark the beginning of changes to the SQL Server table.

  3. Use the Remove method of the Checks collection of a Table object. Indicate the targeted integrity constraint using the constraint name or the ordinal location in the collection, as in:

    oTables("Order Details").Checks.Remove("CK_Order Details_Discount")
    
  4. Use the DoAlter method of the Table object to submit the changed table definition to SQL Server.

Vedere anche

Altre risorse

ALTER TABLE (Transact-SQL)
CREATE TABLE (Transact-SQL)

Guida in linea e informazioni

Assistenza su SQL Server 2005