Share via


Checks Propiedad

Representa una colección de objetos Check. Cada objeto Check representa una restricción CHECK definida en la tabla.

Espacio de nombres:  Microsoft.SqlServer.Management.Smo
Ensamblado:  Microsoft.SqlServer.Smo (en Microsoft.SqlServer.Smo.dll)

Sintaxis

'Declaración
<SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny,  _
    GetType(Check), SfcObjectFlags.Design)> _
Public ReadOnly Property Checks As CheckCollection
    Get
'Uso
Dim instance As Table
Dim value As CheckCollection

value = instance.Checks
[SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Check), SfcObjectFlags.Design)]
public CheckCollection Checks { get; }
[SfcObjectAttribute(SfcContainerRelationship::ChildContainer, SfcContainerCardinality::ZeroToAny, 
    typeof(Check), SfcObjectFlags::Design)]
public:
property CheckCollection^ Checks {
    CheckCollection^ get ();
}
[<SfcObjectAttribute(SfcContainerRelationship.ChildContainer, SfcContainerCardinality.ZeroToAny, 
    typeof(Check), SfcObjectFlags.Design)>]
member Checks : CheckCollection
function get Checks () : CheckCollection

Valor de la propiedad

Tipo: Microsoft.SqlServer.Management.Smo. . :: . .CheckCollection
Objeto Check que representa todas las restricciones CHECK definidas en la tabla.

Ejemplos

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

C#

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

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("AdventureWorks2008R2")

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