Instance.Create Method
Compiles the instance and application metadata and creates instance and application databases.
命名空間: Microsoft.SqlServer.Management.Nmo
組件: Microsoft.SqlServer.Smo (in microsoft.sqlserver.smo.dll)
語法
'宣告
Public Sub Create
public void Create ()
public:
void Create ()
public void Create ()
public function Create ()
備註
The account that you use to create an instance of Notification Services must be a member of the sysadmin fixed server role.
The database and schema in which the Notification Services instance is created is based on the specification of the DatabaseName and SchemaName properties.
To test or deploy an instance of Notification Services, you must perform several additional steps, which are documented in the 部署 Notification Services 的執行個體 section.
範例
The following examples show how to create, register, and enable an instance of 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.")
執行緒安全性
Any public static (Shared in Microsoft Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
平台
開發平台
如需受支援的平台清單,請參閱<安裝 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 命令