次の方法で共有


Table.RowCount プロパティ

テーブル内の行数を取得します。

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

構文

'宣言
<SfcPropertyAttribute(SfcPropertyFlags.Standalone)> _
Public ReadOnly Property RowCount As Long 
    Get
'使用
Dim instance As Table 
Dim value As Long 

value = instance.RowCount
[SfcPropertyAttribute(SfcPropertyFlags.Standalone)]
public long RowCount { get; }
[SfcPropertyAttribute(SfcPropertyFlags::Standalone)]
public:
property long long RowCount {
    long long get ();
}
[<SfcPropertyAttribute(SfcPropertyFlags.Standalone)>]
member RowCount : int64
function get RowCount () : long

プロパティ値

型: System.Int64
テーブル内の行数を示す Int64 値。

使用例

次のコード例では、AdventureWorks2012 データベースの各テーブルに含まれる行の数を表示します。

C#

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

foreach (Table tb in db.Tables) 
{
   Console.WriteLine("The " + tb.Name + " contains " + tb.RowCount + " rows.");
}

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 "conains" $tb.RowCount "rows."
}

関連項目

参照

Table クラス

Microsoft.SqlServer.Management.Smo 名前空間

その他の技術情報

テーブル

CREATE TABLE (Transact-SQL)