Table.Checks Table.Checks Table.Checks Property


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

 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.


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


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.");  


$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