Server.AffinityInfo Server.AffinityInfo Server.AffinityInfo Property


Gets the AffinityInfo object that is associated with an instance of SQL Server.

 property Microsoft::SqlServer::Management::Smo::AffinityInfo ^ AffinityInfo { Microsoft::SqlServer::Management::Smo::AffinityInfo ^ get(); };
[Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObject(Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObjectRelationship.ChildObject, Microsoft.SqlServer.Management.Sdk.Sfc.Metadata.SfcObjectCardinality.One)]
public Microsoft.SqlServer.Management.Smo.AffinityInfo AffinityInfo { get; }
Public ReadOnly Property AffinityInfo As AffinityInfo
Property Value

The AffinityInfo object for specified instance of SQL Server.


The following example shows how to set all the CPUs on an instance of SQL Server to hard affinity.

Visual Basic

using System;  
using Microsoft.SqlServer.Management.Smo;  

namespace samples  
    class Program  
        static void Main(string[] args)  
            Server dbServer = new Server("(local)");  
            dbServer.AffinityInfo.Cpus[1].AffinityMask = true;  

            dbServer.AffinityInfo.AffinityType = AffinityType.Manual;  

            foreach (Cpu cpu in dbServer.AffinityInfo.Cpus)  
                cpu.AffinityMask = true;  



$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")  
$dbServer.AffinityInfo.AffinityType = [Microsoft.SqlServer.Management.Smo.AffinityType]'Manual'  

foreach ($cpu In $dbServer.AffinityInfo.Cpus)  
   $cpu.AffinityMask = $True  


To get AffinityInfo object properties, users can be a member of the public fixed server role.

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

To create a AffinityInfo object, users must have ALTER ANY APPLICATION role permission on the parent database.

To drop an AffinityInfo object, users must be the owner of the application role or have ALTER ANY APPLICATION role permission on the parent database.

To grant, deny, and revoke permission on the AffinityInfo object, users must have CONTROL permission on the application role.

Applies to