Muokkaa

Jaa


Server configuration: scan for startup procs

Applies to: SQL Server

This article describes how to configure the scan for startup procs server configuration option in SQL Server by using SQL Server Management Studio or Transact-SQL. Use the scan for startup procs option to scan for automatic execution of stored procedures at SQL Server startup time. If this option is set to 1, SQL Server scans for and runs all automatically run stored procedures that are defined on the server. The default value for scan for startup procs is 0 (don't scan).

Recommendations

This option is an advanced option and should be changed only by an experienced database administrator or certified SQL Server professional.

The value for this option can be set by using sp_configure; however, the option is set automatically if you use sp_procoption, which is used to mark or unmark automatically run stored procedures. When sp_procoption is used to mark the first stored procedure as an autoproc, this option is set automatically to a value of 1. When sp_procoption is used to unmark the last stored procedure as an autoproc, this option is automatically set to a value of 0. If you use sp_procoption to mark and unmark autoprocs, and if you always unmark autoprocs before dropping them, there's no need to set this option manually.

Permissions

Execute permissions on sp_configure with no parameters or with only the first parameter are granted to all users by default. To execute sp_configure with both parameters to change a configuration option or to run the RECONFIGURE statement, a user must be granted the ALTER SETTINGS server-level permission. The ALTER SETTINGS permission is implicitly held by the sysadmin and serveradmin fixed server roles.

Use SQL Server Management Studio

  1. In Object Explorer, right-click a server and select Properties.

  2. Select the Advanced node.

  3. Under Miscellaneous, change the Scan for Startup Procs option to True or False by selecting the value you want from the dropdown list box.

Use Transact-SQL

  1. Connect to the Database Engine.

  2. From the Standard bar, select New Query.

  3. Copy and paste the following example into the query window and select Execute. This example shows how to use sp_configure to set the value of the scan for startup procs option to 1.

    USE master;
    GO
    
    EXECUTE sp_configure 'show advanced options', 1;
    GO
    
    RECONFIGURE;
    GO
    
    EXECUTE sp_configure 'scan for startup procs', 1;
    GO
    
    RECONFIGURE;
    GO
    
    EXECUTE sp_configure 'show advanced options', 0;
    GO
    
    RECONFIGURE;
    GO
    

Follow up: After you configure the scan for startup procs option

The server must be restarted before the setting can take effect.