共用方式為


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 值,這個值會指定資料表中的資料列數目。

範例

The following code example displays the number of rows contained in each table of the AdventureWorks2008R2 database.

C#

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

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

Foreach ($tb in $db.Tables) 
{
   Write-Host "The" $tb.Name "conains" $tb.RowCount "rows."
}