AffinityInfo.AffinityType Property

Gets or Sets the AffinityType() member of the AffinityInfo class. Valid values are Auto or Manual.

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

Syntax

'Declaration
Public Property AffinityType As AffinityType
    Get
    Set
'Usage
Dim instance As AffinityInfo
Dim value As AffinityType

value = instance.AffinityType

instance.AffinityType = value
public AffinityType AffinityType { get; set; }
public:
property AffinityType AffinityType {
    AffinityType get ();
    void set (AffinityType value);
}
member AffinityType : AffinityType with get, set
function get AffinityType () : AffinityType
function set AffinityType (value : AffinityType)

Property Value

Type: Microsoft.SqlServer.Management.Smo.AffinityType
The current value of the AffinityType() member.

Remarks

Changes are not applied to the Instance of SQL Server until Alter or Server() method is called.

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

Examples

This example shows you how to display the local instance of SQL Server's AffinityType() setting and then change that setting to the Auto Affinity type.

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

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

            //Retrieve the servers AffinityInfo settings and
            //display the current AffinityType setting.
            dbServer.Refresh();
            Console.WriteLine(dbServer.AffinityInfo.AffinityType);

            //Change the AffinityType setting to Auto and
            //update the server with the new setting.
            dbServer.AffinityInfo.AffinityType = AffinityType.Auto;
            dbServer.AffinityInfo.Alter();
        }
    }
}

Powershell

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

#Retrieve the servers AffinityInfo settings and
#display the current AffinityType setting.
$dbServer.Refresh()
Write-Host $dbServer.AffinityInfo.AffinityType

#Change the AffinityType setting to Auto and
#update the server with the new setting.
$dbServer.AffinityInfo.AffinityType =  [Microsoft.SqlServer.Management.Smo.AffinityType]'Auto'
$dbServer.AffinityInfo.Alter()