Environment: dbatools 2.8.2 (also seen on 2.7.1), SQL Server
Description:
Copy-DbaDbTableData in -Query mode still requires -Table to be specified, even though the query itself already determines what's being read from the source. Omitting -Table when using -Query produces a generic error that doesn't mention -Query at all:
You must pipe in a table or specify SqlInstance, Database and [View|Table]
Repro:
- Run
Copy-DbaDbTableData -SqlInstance <src> -Database <db> -Query "SELECT ..." -DestinationSqlInstance <dst> -DestinationDatabase <db> -DestinationTable <table> without -Table.
- Result: the error above, which reads as if
-SqlInstance/-Database were missing (they weren't) rather than pointing at the actual missing parameter.
Where this bit us:
Hit this while chunked-transferring a large partitioned table (date-column chunking via -Query), the most expensive case to get an unclear error on.
Expected:
Either drop the -Table requirement when -Query is supplied (since the query already defines the source), or make the error message explicitly say that -Table is required alongside -Query in this mode.
Workaround used:
Always pass -Table alongside -Query, even though the query is what actually determines the source data.
Environment: dbatools 2.8.2 (also seen on 2.7.1), SQL Server
Description:
Copy-DbaDbTableDatain-Querymode still requires-Tableto be specified, even though the query itself already determines what's being read from the source. Omitting-Tablewhen using-Queryproduces a generic error that doesn't mention-Queryat all:Repro:
Copy-DbaDbTableData -SqlInstance <src> -Database <db> -Query "SELECT ..." -DestinationSqlInstance <dst> -DestinationDatabase <db> -DestinationTable <table>without-Table.-SqlInstance/-Databasewere missing (they weren't) rather than pointing at the actual missing parameter.Where this bit us:
Hit this while chunked-transferring a large partitioned table (date-column chunking via
-Query), the most expensive case to get an unclear error on.Expected:
Either drop the
-Tablerequirement when-Queryis supplied (since the query already defines the source), or make the error message explicitly say that-Tableis required alongside-Queryin this mode.Workaround used:
Always pass
-Tablealongside-Query, even though the query is what actually determines the source data.