Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/mercurial/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql server 如何迭代Microsoft.SqlServer.Management.Smo中每个表的IndexCollection_Sql Server_Smo - Fatal编程技术网

Sql server 如何迭代Microsoft.SqlServer.Management.Smo中每个表的IndexCollection

Sql server 如何迭代Microsoft.SqlServer.Management.Smo中每个表的IndexCollection,sql-server,smo,Sql Server,Smo,我正试图在我的Microsoft.SqlServer.Management.Smo应用程序中获取每个表的索引和约束列表,但我一开始很难获取索引列表 如果我没有弄错的话,每个表都有一个索引属性,它的类型是IndexCollection,它看起来像是有一个IndexCollections集合作为它的项或元素 例如,如果我引用了一个名为tbl的SQL Server表,我可以引用indexes集合,如下所示: tbl.Indexes 如何遍历索引集合并获取索引列表?尝试以下方法: // iterat

我正试图在我的
Microsoft.SqlServer.Management.Smo
应用程序中获取每个表的索引和约束列表,但我一开始很难获取索引列表

如果我没有弄错的话,每个表都有一个
索引
属性,它的类型是
IndexCollection
,它看起来像是有一个
IndexCollections
集合作为它的项或元素

例如,如果我引用了一个名为
tbl
的SQL Server表,我可以引用indexes集合,如下所示:

tbl.Indexes 

如何遍历
索引
集合并获取索引列表?

尝试以下方法:

// iterate over the indexes for this table
foreach (Index ix in tbl.Indexes)
{
    string indexName = ix.Name;
    string indexType = ix.IndexType.ToString();
    string indexFilter = ix.FilterDefinition;
}
IndexCollection
是一个类型为
Index
的对象集合,其中包含许多属性以获取有关索引的信息