4

Query Store is available in SQL Server 2016+ and on Azure SQL DB it is on by default. With an on-premises SQL Server, it has to be started on each database individually.

Is there a way I can have Query Store on by default when new databases are created?

7

Query Store is not active for new databases by default.

If you turn it on for model database, it will be on for any new databases you create in the same instance. I tested in SQL 2017.

To turn it on in model database run following:

ALTER DATABASE model SET QUERY_STORE = ON; 

I suggest you read this article and decide if you want to turn it on for all databases and settings you want to modify.

Best Practice with the Query Store

  • 1
    Note: If you restore a database that did NOT already have query store = on, it will remain off until activated. Model will only start Query Store on new databases created on the instance. – James Jenkins Jan 26 '18 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.