sp_clearstats

Initiates a new accounting period for all server users or for a specified user. Prints statistics for the previous period by executing sp_reportstats.

Syntax

sp_clearstats [loginame]

Parameters

Examples

Usage

sp_clearstats creates an accounting period and should be run only at the end of a period.

Because sp_clearstats clears out the accounting statistics, you must record the statistics before running the procedure.

sp_clearstats updates the syslogins field accdate and clears the syslogins fields totcpu and totio.

Permissions

The permission checks for sp_clearstats differ based on your granular permissions settings.

SettingDescription
Enabled

With granular permissions enabled, you must be a user with manage server privilege.

Disabled

With granular permissions disabled, you must be a user with sa_role.

Auditing

Values in event and extrainfo columns from the sysaudits table are:

InformationValues
Event

38

Audit option

exec_procedure

Command or access audited

Execution of a procedure

Information in extrainfo
  • Roles – Current active roles

  • Keywords or options – NULL

  • Previous value – NULL

  • Current value – NULL

  • Other information – All input parameters

  • Proxy information – Original login name, if set proxy in effect

Related reference
sp_reportstats