共用方式為


Alter 方法

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

命名空間:  Microsoft.SqlServer.Management.Smo
組件:  Microsoft.SqlServer.Smo (在 Microsoft.SqlServer.Smo.dll 中)

語法

'宣告
Public Sub Alter
'用途
Dim instance As AffinityInfo

instance.Alter()
public void Alter()
public:
virtual void Alter() sealed
abstract Alter : unit -> unit 
override Alter : unit -> unit 
public final function Alter()

實作

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()