dbatools is a free PowerShell module with over 200 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Set-DbaQueryStoreConfig

Configure Query Store settings for a specific or multiple databases.

Screenshots

Examples

Configure the Query Store settings for all user databases in the ServerA\SQL Instance.

Set-DbaQueryStoreConfig -SqlServer ServerA\SQL -State ReadWrite -FlushInterval 600 -CollectionInterval 10 -MaxSize 100 -CaptureMode All -CleanupMode Auto -StaleQueryThreshold 100 -AllDatabases

Configure the Query Store settings for the AdventureWorks database in the ServerA\SQL Instance.

Set-DbaQueryStoreConfig -SqlServer ServerA\SQL -Databases AdventureWorks -State ReadWrite -FlushInterval 600 -CollectionInterval 10 -MaxSize 100 -CaptureMode all -CleanupMode Auto -StaleQueryThreshold 100

Configure the Query Store settings for all user databases except the AdventureWorks database in the ServerA\SQL Instance.

Set-DbaQueryStoreConfig -SqlServer ServerA\SQL -Exclude AdventureWorks -State ReadWrite -FlushInterval 600 -CollectionInterval 10 -MaxSize 100 -CaptureMode all -CleanupMode Auto -StaleQueryThreshold 100

Author

This command was created by Enrico van de Laar. You can follow Enrico on Twitter at @evdlaar.

Get-Help

From PowerShell, execute Get-Help Set-DbaQueryStoreConfig -Detailed for more information on this function.

Source Code

Want to see the source code? View Set-DbaQueryStoreConfig.ps1 on GitHub
 

Related commands