Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

AffinityInfo.Alter Method

This method updates the server with the current values in the AffinityInfo class.

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

public void Alter()

Implements

IAlterable.Alter()

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

This example shows you how to set an Instance of SQL Server to Auto 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.Refresh();
            dbServer.AffinityInfo.AffinityType = AffinityType.Auto;
            dbServer.AffinityInfo.Alter();
        }
    }
}

Powershell

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

//Set the Affinity Type to Auto
#dbServer.AffinityInfo.Refresh()
$dbServer.AffinityInfo.AffinityType = [Microsoft.SqlServer.Management.Smo.AffinityType]'Auto'
$dbServer.AffinityInfo.Alter() 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft. All rights reserved.