Skip to content

Copy-DbaDbTableData verbose progress counter over-reports rows copied on final batch #10675

Description

@JankeUwe

Environment: dbatools 2.8.2 (also seen on 2.7.1), SQL Server

Description:
The live progress number Copy-DbaDbTableData writes to its verbose stream (e.g. "adjusted total rows copied = N") can over-report versus the destination table's real row count once the copy finishes. This looks like the command's own internal bookkeeping - built to work around SqlBulkCopy's legacy 32-bit RowsCopied counter - has a double-counting edge case on the final batch.

Repro:

  • Run Copy-DbaDbTableData with -Verbose on a table large enough to span multiple batches (-BatchSize).
  • Watch the verbose "adjusted total rows copied" value as the final batch completes.
  • Compare against SELECT COUNT_BIG(*) on the destination table after the run finishes.
  • The verbose total can be higher than the real row count.

Impact:
Cosmetic only - the extra count is not reflected in what's actually written to the destination, confirmed by a real COUNT_BIG(*) afterwards. But it's misleading for anyone live-monitoring a large transfer and expecting the reported total to match the final row count, and it can make a clean transfer look like it over-copied when it didn't.

Expected:
The verbose "rows copied" total should match the destination's actual row count once the last batch completes, or the discrepancy should be documented as a known artifact of the 32-bit counter workaround.

Workaround used:
Don't trust the live verbose counter for the final total - do a direct COUNT_BIG(*) comparison against source/destination after the transfer instead.

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