Export (0) Print
Expand All

Table.CheckTable Method

Tests the integrity of database pages for the table and indexes defined on the table.

Namespace:  Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public StringCollection CheckTable()

Return Value

Type: StringCollection
A StringCollection system object value that contains the results of the checking the integrity of the table, including the number of rows and the number of pages.

This method is functionally equivalent to the Transact-SQL CHECK TABLE statement.

C#

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

foreach (Table tb in db.Tables)
{
   tb.CheckTable();
}

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)
{
   $tb.CheckTable()
}
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft