< Back
Copy-DbaDbQueryStoreOption
Post
NAME Copy-DbaDbQueryStoreOption
SYNOPSIS
Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.
SYNTAX
Copy-DbaDbQueryStoreOption [-Source] <DbaInstanceParameter> [[-SourceSqlCredential] <Pscredential>]
[-SourceDatabase] <System.Object> [-Destination] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>
[[-DestinationSqlCredential] <Pscredential>] [[-DestinationDatabase] <System.Object[]>] [[-Exclude]
<System.Object[]>] [-AllDatabases <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.
PARAMETERS
-AllDatabases [<Switch>]
If this switch is enabled, the Query Store configuration will be copied to all databases on the destination
instance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Destination [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2016 or higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DestinationDatabase [<System.Object[]>]
Specifies a list of databases that will receive a copy of the Query Store configuration of the SourceDatabase.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DestinationSqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Exclude [<System.Object[]>]
Specifies a list of databases which will NOT receive a copy of the Query Store configuration.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Source [<DbaInstanceParameter>]
Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2016 or higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SourceDatabase [<System.Object>]
Specifies the database to copy the Query Store configuration from.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SourceSqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: QueryStore
Author: Enrico van de Laar (@evdlaar) | Tracy Boggiano ( @Tracy Boggiano)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Copy-DbaDbQueryStoreOption -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL
-AllDatabases
Copy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it on all
user databases in the ServerB\\SQL Instance.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Copy-DbaDbQueryStoreOption -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL
-DestinationDatabase WorldWideTraders
Copy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it to the
WorldWideTraders database in the ServerB\\SQL Instance.
RELATED LINKS
https://dbatools.io/Copy-QueryStoreConfig
SYNOPSIS
Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.
SYNTAX
Copy-DbaDbQueryStoreOption [-Source] <DbaInstanceParameter> [[-SourceSqlCredential] <Pscredential>]
[-SourceDatabase] <System.Object> [-Destination] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>
[[-DestinationSqlCredential] <Pscredential>] [[-DestinationDatabase] <System.Object[]>] [[-Exclude]
<System.Object[]>] [-AllDatabases <Switch>] [-EnableException <Switch>] [<CommonParameters>]
DESCRIPTION
Copies the configuration of a Query Store enabled database and sets the copied configuration on other databases.
PARAMETERS
-AllDatabases [<Switch>]
If this switch is enabled, the Query Store configuration will be copied to all databases on the destination
instance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Destination [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]
Destination SQL Server. You must have sysadmin access and the server must be SQL Server 2016 or higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DestinationDatabase [<System.Object[]>]
Specifies a list of databases that will receive a copy of the Query Store configuration of the SourceDatabase.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-DestinationSqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-EnableException [<Switch>]
By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables
advanced scripting.
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own
try/catch.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Exclude [<System.Object[]>]
Specifies a list of databases which will NOT receive a copy of the Query Store configuration.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-Source [<DbaInstanceParameter>]
Source SQL Server. You must have sysadmin access and server version must be SQL Server version 2016 or higher.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SourceDatabase [<System.Object>]
Specifies the database to copy the Query Store configuration from.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
-SourceSqlCredential [<Pscredential>]
Login to the target instance using alternative credentials. Accepts PowerShell credentials (Get-Credential).
Windows Authentication, SQL Server Authentication, Active Directory - Password, and Active Directory -
Integrated are all supported.
For MFA support, please use Connect-DbaInstance.
Required? false
Position? named
Default value
Accept pipeline input? False
Accept wildcard characters? false
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
NOTES
Tags: QueryStore
Author: Enrico van de Laar (@evdlaar) | Tracy Boggiano ( @Tracy Boggiano)
Website: https://dbatools.io
Copyright: (c) 2018 by dbatools, licensed under MIT
License: MIT https://opensource.org/licenses/MIT
-------------------------- EXAMPLE 1 --------------------------
PS C:\\>Copy-DbaDbQueryStoreOption -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL
-AllDatabases
Copy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it on all
user databases in the ServerB\\SQL Instance.
-------------------------- EXAMPLE 2 --------------------------
PS C:\\>Copy-DbaDbQueryStoreOption -Source ServerA\\SQL -SourceDatabase AdventureWorks -Destination ServerB\\SQL
-DestinationDatabase WorldWideTraders
Copy the Query Store configuration of the AdventureWorks database in the ServerA\\SQL instance and apply it to the
WorldWideTraders database in the ServerB\\SQL Instance.
RELATED LINKS
https://dbatools.io/Copy-QueryStoreConfig