INF: How to Benefit From Autoexec Stored Procedures

Last reviewed: April 8, 1997
Article ID: Q151366

The information in this article applies to:
  • Microsoft SQL Server, versions 6.0 & 6.5

SUMMARY

This article explains how to benefit from auto executing stored procedures to perform certain system administration tasks.

MORE INFORMATION

In versions 6.0 and 6.5, you can have one or more stored procedures execute automatically when SQL Server starts. The stored procedures must be created by the system administrator (SA) and will execute under the SA account as a background process.

During start-up, SQL Server checks for stored procedures in the master database that have been marked for start-up, launches the exception handler to handle any exception raised during the execution of the stored procedures and then writes an entry into the SQL Server errorlog. Execution of the stored procedures starts when the last database has been recovered at startup.

The following are some system administration tasks that can benefit from this feature:

  1. Correct the page count discrepancy in the SYSLOGS table.

    See the following Knowledge Base article for more information:

          Q39113, PRB: DBCC Reports Page Count Discrepancy on SYSLOGS Table
    

  2. Update the statistics on the distribution of the key values in the indexes.

    This can be done with the UPDATE STATISTICS statement which creates or updates information about the distribution of the key values in the indexes. This helps SQL Server determine which indexes to use when processing a query. You should use this statement when a large amount of data in an indexed column has been added, changed, or deleted. Please refer to Update Statistics command in the "Transact-SQL Reference" manual for additional information.

Also refer to the "Transact-SQL Reference" manual for information on how to create, delete, gather information, and disable auto execution stored procedures.

SQL Server 6.5 users can use the Database Maintenance Plan Wizard to perform the above mentioned system administration tasks.


Additional query words: sp_unmakestartup sp_makestartup sp_helpstartup
Keywords : kbusage SSrvStProc SSrvTran_SQL
Version : 6.0 6.5
Platform : WINDOWS
Issue type : kbhowto


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: April 8, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.