Table.Checks Table.Checks Table.Checks Property

Definition

Represents a collection of Check objects. Each Check object represents a check constraint defined on the table.

public:
 property Microsoft::SqlServer::Management::Smo::CheckCollection ^ Checks { Microsoft::SqlServer::Management::Smo::CheckCollection ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerRelationship.ChildContainer, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcContainerCardinality.ZeroToAny, typeof(Microsoft.SqlServer.Management.Smo.Check), Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObjectFlags.Design)]
public Microsoft.SqlServer.Management.Smo.CheckCollection Checks { get; }
Public ReadOnly Property Checks As CheckCollection
Property Value

A Check object that represents all the check constraints that are defined on the table.

Examples

The following code example shows how to display the names of each check constraint on each AdventureWorks2012 table.

C#

Server srv = new Server("(local)");  
Database db = srv.Databases["AdventureWorks2012"];  

foreach (Table tb in db.Tables)  
{  
   foreach (Check ck in tb.Checks)  
   {  
      Console.WriteLine("The " + tb.Name + " table has the " + ck.ToString() + " check.");  
   }  
}  

Powershell

$srv = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$db = New-Object Microsoft.SqlServer.Management.Smo.Database  
$db = $srv.Databases.Item("AdventureWorks2012")  

Foreach ($tb in $db.Tables)  
{  
   Foreach ($ck in $tb.Checks)  
   {  
      Write-Host "The" $tb.Name "table has the" $ck "check."  
   }  
}  

Applies to