Sdílet prostřednictvím


nscontrol enable Command

Enables the specified SQL Server Notification Services instance, application, or component.

Syntax

nscontrol enable 
    [-nologo]
    [-help]
    [< component > [...n]]
        -name instanceName
    [-server databaseServer]
    [-application applicationName]
    [-sqlusername sqlUserName -sqlpassword sqlPassword]

< component > ::=
    -events [systemName]
    | -generator
    | -distributor [ systemName ]
    | -subscriptions
    | -subscribers 

Arguments

  • -nologo
    Suppresses the product and version statement that appears when you run an nscontrol command.
  • -help
    Displays the command syntax.
  • < component >
    Specifies a component to enable. You can specify zero or more components when you run nscontrol enable.

    If you do not specify a component name, all components of the instance or application are enabled. If you specify a component but do not specify an application name using the -application argument, then all matching components in all applications hosted by the instance are enabled.

    < component > can be any of the following arguments:

    Argument Description

    -distributor [systemName]

    Enables distribution for the instance or application. If you specify a distributor system name, the distributors on only that system are enabled. Otherwise, all the distributors for the instance or application are enabled.

    -events [systemName]

    Enables hosted event providers for the instance or application. If you specify -events with a system name, the hosted event providers on only that system are enabled. Otherwise, all hosted event providers for the instance or application are enabled.

    -generator

    Enables the generator.

    -subscriptions

    Enables subscription management.

    -subscribers

    Enables subscriber management for the instance of Notification Services.

  • -nameinstanceName
    Is the name of the instance that is affected by nscontrol enable. If you specify the –name argument without specifying –application or a component, the nscontrol utility enables all instance applications and components.

    See the -server argument for information about using the -name argument with the -server argument.

  • -serverdatabaseServer
    Is the name of the server that hosts the instance and application databases. If you use a named instance of SQL Server to host the databases, you must specify the server name and the instance name using the format <servername>\<instancename>.

    When you run nscontrol enable on a system where the instance has previously been registered using the nscontrol register command, use the -name argument but not the -server argument. The nscontrol utility determines the SQL Server instance name by reading the registry information of the instance.

    When you run nscontrol enable on a system where the instance is not registered, you must use both the -name and -server arguments, because the nscontrol utility needs both the Notification Services instance name and the SQL Server instance name to locate the instance database.

    When you specify the -server argument, the nscontrol utility ignores any registry values for the instance.

  • -applicationapplicationName
    Is the name of the application for which one or all components are being enabled. If you do not specify an application name, specified components are enabled for all applications that are hosted by the instance.
  • -sqlusernamesqlUserName
    Is the SQL Server login used to connect to SQL Server.

    If you are using SQL Server Authentication to connect to SQL Server, specify a login using this argument. Also specify a password using the sqlpassword argument.

    If you are using Windows Authentication, do not specify the -sqlusername and -sqlpassword arguments.

    Important

    When possible, use Windows Authentication.

  • -sqlpasswordsqlPassword
    Is the password that is associated with the -sqlusername login. This argument must be used together with the sqlusername argument.

Remarks

The nscontrol enable command changes the status of the specified components to Enable Pending by updating a value in a database. Instance state is stored in the instance database. Individual component state is stored in the application database.

When you run nscontrol enable, Notification Services broadcasts the desired state change to all components. The state changes from Enable Pending to Enabled after all running components have responded to the change. With the exception of the subscriber and subscription components, the engine (typically, the NS$instance_name Windows service) must be running for component states to change from Enable Pending to Enabled. However, changing the state from Enable Pending to Disabled, or from Disable Pending to Enabled, does not require the service to be running, because these actions simply cancel a pending operation.

After nscontrol enable modifies the database, it displays the current status of the instance, the applications, and the components. For descriptions of the status values, see Viewing the Status of Instances, Applications, and Components.

When an NS$<instance_name> service starts, it determines where it is running (its host name) and then compares this value to the SystemName value for each distributor, hosted event provider, and generator. If the host name matches the SystemName value, the service checks the component state. If the component is enabled, it starts.

While the service is running, it checks the database every 30 seconds to determine the state of the hosted event providers, the generator, and the distributors.

The subscribers and subscriptions state is cached on the database server, and the subscription management objects check this state before they perform subscription or subscriber operations.

Permissions

The account used to run nscontrol enable, or the SQL Server login specified by the -sqlusername argument, can obtain the proper permissions through membership in the NSAdmin database role in individual application and instance databases. Members of the db_owner database role and the sysadmin and dbcreator fixed server roles also can run nscontrol enable.

The account must also have permission to execute the Notification Services binary files; this permission is granted to members of the Administrators and SQLServerNotificationServicesUser Windows groups.

Examples

A. Enabling an instance of Notification Services

The following example enables an entire instance of Notification Services named StockInstance. The instance must be registered on the computer where you run the following command.

nscontrol enable -name StockInstance

B. Enabling a single application

The following example enables all components of the Stock application on the StockInstance instance of Notification Services. The nscontrol command uses Windows Authentication to connect to SQL Server. The instance must be registered on the computer where you run the command.

nscontrol enable -name StockInstance -application Stock

C. Enabling all hosted event providers

The following example enables hosted event providers for all applications in the StockInstance instance of Notification Services. The nscontrol****command uses Windows Authentication to connect to SQL Server. The instance must be registered on the computer where you run the command.

nscontrol enable -name StockInstance -events

D. Enabling an instance from an administration computer

If you run nscontrol enable from a computer where StockInstance is not registered, you must supply the SQL Server instance name using the -server argument. The following example shows how to enable an instance when the databases are on an instance of SQL Server named nsuetest. The nscontrol command uses Windows Authentication to connect to SQL Server.

nscontrol enable -name StockInstance -server nsuetest

E. Using SQL Server Authentication to enable an instance of Notification Services

The following example enables an entire instance of Notification Services named StockInstance, using SQL Server Authentication to connect to SQL Server. The instance must be registered on the computer where you run the following command.

nscontrol enable -name StockInstance -sqlusername SqlUser 
    -sqlpassword sQl-P@sWd

See Also

Reference

nscontrol Utility

Other Resources

Enabling and Disabling Instances, Applications, or Components

Help and Information

Getting SQL Server 2005 Assistance

Change History

Release History

5 December 2005

New content:
  • Added information about the SQLServerNotificationServicesUser Windows group.