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


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