Cpus 屬性
The Cpus()()()() member is a collection that represents the CPU settings for all CPUs on an Instance of SQL Server.
命名空間: Microsoft.SqlServer.Management.Smo
組件: Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)
語法
'宣告
Public ReadOnly Property Cpus As CpuCollection
Get
'用途
Dim instance As AffinityInfo
Dim value As CpuCollection
value = instance.Cpus
public CpuCollection Cpus { get; }
public:
property CpuCollection^ Cpus {
CpuCollection^ get ();
}
member Cpus : CpuCollection
function get Cpus () : CpuCollection
屬性值
型別:Microsoft.SqlServer.Management.Smo. . :: . .CpuCollection
Returns a CPUCollection.
備註
Access to the Cpus collection is provided though the [T:Microsoft.SqlServer.Management.Smo.AffinityInfo.] member of the Server object.
範例
This example shows you how to create and display the CPU information for all CPUs on the local instance of SQL Server.
using System;
using Microsoft.SqlServer.Management.Smo;
namespace samples
{
class Program
{
static void Main(string[] args)
{
Server dbServer = new Server("(local)");
dbServer.Refresh();
Console.WriteLine("Total CPUs: {0}\n", dbServer.AffinityInfo.Cpus.Count);
foreach (Cpu cpu in dbServer.AffinityInfo.Cpus)
{
Console.WriteLine("cpu.ID: {0}\n" +
"cpu.GroupID: {1}\n" +
"cpu.AffinityMask: {2}\n" +
"cpu.NumaNodeID: {3}\n",
cpu.ID,
cpu.GroupID,
cpu.AffinityMask,
cpu.NumaNodeID);
}
}
}
}
Powershell
#Create the server.
$dbServer = new-Object Microsoft.SqlServer.Smo.Server("(local)")
$dbServer.Refresh()
Write-Host "Total CPUs: Microsoft.SqlServer.Smo`n, $dbServer.AffinityInfo.Cpus.Count"
Foreach ($cpu in $dbServer.AffinityInfo.Cpus)
{
Write-Host $cpu
}