Share via


Instance.Create Method

インスタンスおよびアプリケーションのメタデータをコンパイルし、インスタンス データベースおよびアプリケーション データベースを作成します。

名前空間: Microsoft.SqlServer.Management.Nmo
アセンブリ: Microsoft.SqlServer.Smo (microsoft.sqlserver.smo.dll 内)

構文

'宣言
Public Sub Create
public void Create ()
public:
void Create ()
public void Create ()
public function Create ()

解説

Notification Services のインスタンスの作成に使用するアカウントは、固定サーバー ロール sysadmin のメンバである必要があります。

Notification Services インスタンスを作成するデータベースとスキーマは、DatabaseName および SchemaName プロパティの指定に基づいて決定されます。

Notification Services のインスタンスをテストまたは配置するには、追加の手順が必要です。この手順は「Notification Services のインスタンスの配置」に記載されています。

使用例

次の例は、Notification Services のインスタンスを作成、登録、および有効にする方法を示しています。

// Set Database Engine instance and 
// Notification Services object
server = new smo.Server(sqlServer);
notificationServices = server.NotificationServices;

// Determine if the instance already exists. If so, exit.
if (server.NotificationServices.Instances.Contains(
    instanceName))
{
    Console.WriteLine("Instance exists and will be deleted.");
    myInstance = notificationServices.Instances[instanceName];
    DeleteInstance(myInstance);
}

// Call ConfigureInstance method to configure the instance
// and define the application(s).
myInstance = ConfigureInstance(notificationServices);

// Create the instance
Console.WriteLine("Creating instance...");
myInstance.Create();

//Optional: Export an Instance Configuration File (ICF)
Console.WriteLine("Exporting ICF...");
myInstance.Export(@"C:\NS\Full", true);

// Register and enable the instance
Console.WriteLine("Registering instance...");
myInstance.RegisterLocal(serviceUserName, servicePassword);
Console.WriteLine("Enabling instance...");
myInstance.Enable();
Console.WriteLine("Done.");
' Set Database Engine server and 
' Notification Services object
server = New smo.Server(sqlServer)
notificationServices = server.NotificationServices

' Determine if the instance already exists. If so, exit.
If server.NotificationServices.Instances.Contains( _
  instanceName) Then
    Console.WriteLine( _
        "Instance exists and will be deleted.")
    myInstance = notificationServices.Instances( _
        instanceName)
    DeleteInstance(myInstance)
End If

' Call ConfigureInstance method to configure the instance
' and define the application(s).
myInstance = ConfigureInstance(notificationServices)

' Create the instance
Console.WriteLine("Creating instance...")
myInstance.Create()

'Optional: Export an Instance Configuration File (ICF)
Console.WriteLine("Exporting ICF...")
myInstance.Export("C:\NS\Full", True)

' Register and enable the instance
Console.WriteLine("Registering instance...")
myInstance.RegisterLocal(serviceUserName, servicePassword)
Console.WriteLine("Enabling instance...")
myInstance.Enable()
Console.WriteLine("Done.")

スレッド セーフ

この型の public static (Microsoft Visual Basic では共有 ) メンバは、スレッド セーフです。インスタンス メンバの場合は、スレッド セーフであるとは限りません。

プラットフォーム

開発プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

対象プラットフォーム

サポートされているプラットフォームの一覧については、「SQL Server 2005 のインストールに必要なハードウェアおよびソフトウェア」を参照してください。

参照

関連項目

Instance Class
Instance Members
Microsoft.SqlServer.Management.Nmo Namespace

その他の技術情報

ユーザーとスキーマの分離
Notification Services の配置
Notification Services のインスタンスを作成する方法 (SQL Server Management Studio)
nscontrol create コマンド