AffinityInfo AffinityInfo AffinityInfo Class

Definition

The AffinityInfo object represents the Affinity settings for all CPUs and NUMA nodes on an Instance of SQL Server. Access to the AffinityInfo object is provided though the Server object.

public ref class AffinityInfo sealed : Microsoft::SqlServer::Management::Smo::AffinityInfoBase
public sealed class AffinityInfo : Microsoft.SqlServer.Management.Smo.AffinityInfoBase
Public NotInheritable Class AffinityInfo
Inherits AffinityInfoBase
Inheritance

Examples

This example shows you how to set all of the CPU’s on an instance of SQL Server to hard affinity.

C#

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

namespace samples  
{  
    class Program  
    {  
        static void Main(string[] args)  
        {  
            Server dbServer = new Server("(local)");  
            dbServer.AffinityInfo.AffinityType = AffinityType.Manual;  

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

            dbServer.AffinityInfo.Alter();  
        }  
    }  
}  

Powershell

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

//Set the Affinity Type  
$dbServer.AffinityInfo.AffinityType = [Microsoft.SqlServer.Management.Smo.AffinityType]'Manual'  

//Set each CPU to Hard affinity and update  
foreach ($cpu In $dbServer.AffinityInfo.Cpus)  
{  
   $cpu.AffinityMask = $True  
   $dbServer.AffinityInfo.Alter()   
}  

Remarks

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 AffinityInfo 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.

Properties

AffinityType AffinityType AffinityType

Gets or sets the affinity type of the AffinityInfoBase.

(Inherited from AffinityInfoBase)
Cpus Cpus Cpus

The Cpus member is a collection that represents the CPU settings for all CPUs on an Instance of SQL Server.

ExecutionManager ExecutionManager ExecutionManager

Gets the execution manager of the AffinityInfoBase.

(Inherited from AffinityInfoBase)
NumaNodes NumaNodes NumaNodes

Gets a collection that contains the NUMA node settings.

(Inherited from AffinityInfoBase)
Parent Parent Parent

This gets the parent object of the AffinityInfo object. This value is the same as the Server object that contains the AffinityInfo member.

Methods

Alter() Alter() Alter()

Updates the AffinityInfo object property changes on the instance of SQL Server.

(Inherited from AffinityInfoBase)
Refresh() Refresh() Refresh()

This method fills in the Cpus and NumaNode with the local server settings.

Script() Script() Script()

Generates a Transact-SQL script.

(Inherited from AffinityInfoBase)
Script(ScriptingOptions) Script(ScriptingOptions) Script(ScriptingOptions)

Generates a Transact-SQL script.

(Inherited from AffinityInfoBase)

Applies to