How to Turn Off Query Store…in an emergency


Have you ever tried to turn off Query Store when there was an issue, and you thought the problem might be related to Query Store, and the ALTER DATABASE statement was blocked?  And then you couldn’t do anything but wait?  Me too.  Imagine my excitement when I discovered that the SQL Server team snuck a helpful back door into ALL versions for which Query Store is supported. 

Wait, what?

If you check the documentation for ALTER DATABASE SET and review the QUERY_STORE section, you’ll see that OFF now includes the optional FORCED parameter.

If you are running:

SQL Server 2016