I have two databases that are in an availability group, one as the primary replica and the other is the secondary. I have a store procedure that returns the following error.
DBCC execution completed. If DBCC printed error messages, contact your system administrator. Msg 2767, Level 16, State 1, Procedure xxxx.sys.sp_table_statistics2_rowset, Line 105 [Batch Start Line 2] Could not locate statistics '_WA_Sys_00000026_0143D405' in the system catalogs. DBCC execution completed. If DBCC printed error messages, contact your system administrator.
when I run the following query on my secondary replica(read-only):
SELECT OBJECT_NAME(s.object_id) AS object_name
, COL_NAME(sc.object_id, sc.column_id) AS column_name
, s.name AS statistics_name
FROM sys.stats AS s
INNER JOIN sys.stats_columns AS sc ON s.stats_id = sc.stats_id AND s.object_id = sc.object_id
WHERE s.name like '%_WA_Sys_00000026_0143D405%'
ORDER BY s.name;
the stat appears:
STOJOU QTYPCU_0 _WA_Sys_00000026_0143D405
STOJOU QTYPCU_0 _WA_Sys_00000026_0143D405_readonly_database_statistics
when I run the query on the Primary replica it does not appear in the system tables but when you look under the table STOJOU it does appear.
How do I rebuild and/or resync the stats between my two systems? I am unable to drop/or create the Stat on my primary. Do I need to stop my synchronization between the primary and secondary to address this? Thanks for your assistance.