Database corruption: QueryStore internal table

As noted in my comment above I had a similar corruption issue with a query store internal table.

As you yourself have suggested I used ALTER DATABASE MyDatabase SET QUERY_STORE CLEAR; to attempt to fix the issue and that did work fine. In SQL Server 2017, Microsoft added a repair procedure that can be attempted prior to clearing the data: sp_query_store_consistency_check (source)

If you want to preserve the data then probably the only method is to copy the tables - I can't find anyone who has created a script for that.

Usually with corruption I too would be worried about my disks, but in this case I'm a little suspicious that the issue is with query store itself.


To answer you question #3

If #2 is the best fix, is there any good way of preserving the data in Query Store that would be deleted?

See How can I export Query Store data? it is not difficult in most cases to export the QS data. I can't say if your error will impact the export.

You may find some data missing when you export, See Why is Query Store missing details?