Skip to content

Copy-DbaDbTableData -Query still requires -Table, with an unhelpful error otherwise #10676

Description

@JankeUwe

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions