AffinityInfo.Refresh Method ()


This method fills in the M:Microsoft.SqlServer.Management.Smo.Cpus and M:Microsoft.SqlServer.Management.Smo.NumaNode with the local server settings.

Namespace:   Microsoft.SqlServer.Management.Smo
Assembly:  Microsoft.SqlServer.Smo (in Microsoft.SqlServer.Smo.dll)

public override void Refresh()

To set any AffinityInfo object properties and users must have ALTER permission on the database.

This example shows you how to determine the number of 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)");
            Console.WriteLine("Total CPUs = {0}",


//Create the server. 
$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")

//Set the Affinity Type to Auto
Write-Host "Total CPUs = ",$dbServer.AffinityInfo.Cpus.Count
Return to top