Flushes statistics from in-memory storage to the systabstats and sysstatistics system tables.
sp_flushstats [objname]
is the name of a table.
Flushes statistics for the titles table:
sp_flushstats titles
When you do not specify a table with the objname parameter, sp_flushstats acts at the database level.
Some statistics in the systabstats table are updated in in-memory storage locations and flushed to systabstats periodically, to reduce overhead and contention on systabstats.
If you query systabstats using SQL, executing sp_flushstats guarantees that in-memory statistics are flushed to systabstats.
The optdiag command always flushes in-memory statistics before displaying output.
The statistics in sysstatistics are changed only by data definition language commands and do not require the use of sp_flushstats.
The in-memory datachange counters are persistently stored in sysstatistics. These are flushed to disk when sp_flushstats is executed.
The permission checks for sp_flushstats differ based on your granular permissions settings.
| Granular permissions enabled | With granular permissions enabled, you must be a user with monitor qp performance privilege. | 
| Granular permissions disabled | With granular permissions disabled, you must be a user with sa_role. | 
Values in event and extrainfo columns from the sysaudits table are:
| Event | Audit option | Command or access audited | Information in extrainfo | 
|---|---|---|---|
| 38 | exec_procedure | Execution of a procedure | 
 |