Export (0) Print
Expand All

CpuCollection.SetAffinityToAll Method

Sets the affinity mask for all CPUs on an instance of SQL Server.

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

public void SetAffinityToAll(
	bool affinityMask
)

Parameters

affinityMask
Type: Boolean
If true, affinity is set for each CPU in the specified range. If false, the affinity state is removed from each CPU in the specified range.

The following example shows how to set affinity to each CPU on an instance of SQL Server.

C#

using System;
using System.Collections.Specialized;
using System.Data;
using Microsoft.SqlServer.Management.Smo;

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

Powershell

$dbServer = new-Object Microsoft.SqlServer.Management.Smo.Server("(local)")
$dbServer.AffinityInfo.AffinityType = [Microsoft.SqlServer.Management.Smo.AffinityType]'Manual'
$dbServer.AffinityInfo.Alter()
$dbServer.AffinityInfo.Cpus.SetAffinityToAll($TRUE)
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft