Check Object
Dieses Feature wird in einer zukünftigen Version von Microsoft SQL Server entfernt. Verwenden Sie dieses Feature beim Entwickeln neuer Anwendungen nicht, und planen Sie das Ändern von Anwendungen, in denen es zurzeit verwendet wird.
The Check object represents the attributes of a single Microsoft SQL Server integrity constraint.
Properties
Methods
Hinweise
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:
- Define a new integrity constraint for a SQL Server table.
- Remove an existing constraint from a SQL Server table.
- Generate a Transact-SQL script to document an existing integrity constraint.
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
Create a Check object.
Set the Name property.
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.
Set the ExcludeReplication property.
Add the Check object to the Checks collection of a Table object.
To remove a SQL Server integrity constraint
Get the appropriate Table object from the Tables collection of a Database object.
Use the BeginAlter method of the Table object to mark the start of alterations on the SQL Server table.
Get the appropriate Check object from the Checks collection of the Table object.
Use the Remove method of the Check object to drop its integrity constraint from the SQL Server table.
Use the DoAlter method of the Table object to submit the change to the instance of SQL Server.
Siehe auch
Andere Ressourcen
ALTER TABLE (Transact-SQL)
CREATE TABLE (Transact-SQL)