次の方法で共有


Table.HasIndex プロパティ

テーブルに少なくとも 1 つのインデックスがあるかどうかを示す Boolean プロパティ値を取得します。

名前空間:  Microsoft.SqlServer.Management.Smo
アセンブリ:  Microsoft.SqlServer.Smo (Microsoft.SqlServer.Smo.dll)

構文

'宣言
<SfcPropertyAttribute(SfcPropertyFlags.None Or SfcPropertyFlags.Standalone Or SfcPropertyFlags.SqlAzureDatabase)> _
Public ReadOnly Property HasIndex As Boolean 
    Get
'使用
Dim instance As Table 
Dim value As Boolean 

value = instance.HasIndex
[SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.SqlAzureDatabase)]
public bool HasIndex { get; }
[SfcPropertyAttribute(SfcPropertyFlags::None|SfcPropertyFlags::Standalone|SfcPropertyFlags::SqlAzureDatabase)]
public:
property bool HasIndex {
    bool get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.None|SfcPropertyFlags.Standalone|SfcPropertyFlags.SqlAzureDatabase)>]
member HasIndex : bool
function get HasIndex () : boolean

プロパティ値

型: System.Boolean
テーブルで少なくとも 1 つのインデックスが定義されているかどうかを示す Boolean 値。 True の場合、テーブルでインデックスが定義されています。False (既定値) の場合、インデックスは定義されていません。

使用例

次のコード例では、AdventureWorks2012 データベースの各テーブルをチェックし、インデックスが含まれているかどうかを確認する方法を示します。

C#

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

Foreach (Table tb in db.Tables) 
{
   Console.WriteLine("The " + tb.Name + " table has an index:" + tb.HasIndex.ToString());
}

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) 
{
   Write-Host "The" $tb.Name "table has an index:" $tb.HasIndex
}

関連項目

参照

Table クラス

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

テーブル

CREATE TABLE (Transact-SQL)