Skip to content

[Bug] Copy-DbaDbTableDate does not copy table data between two different Azure SQL Databases #6743

@gbargsley

Description

@gbargsley

Environmental information

PowerShell Version        : 5.1.14393.3471
dbatools latest installed : 1.0.115
Culture of OS             : en-US

SQL Server:

Source = Microsoft SQL Azure (RTM) - 12.0.2000.8   Jul 31 2020 08:26:29   Copyright (C) 2019 Microsoft Corporation 
Destination = Microsoft SQL Azure (RTM) - 12.0.2000.8   Jul 31 2020 08:26:29   Copyright (C) 2019 Microsoft Corporation 
Source = us_english
Destination = us_english

Report

Host used

  • powershell.exe
  • ISE
  • VS Code
  • Other (please specify)

If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe

  • Still buggy in powershell.exe

Errors Received

Screen output:

VERBOSE: [10:54:19][Connect-DbaInstance] Connecting to Data Source=TCP:source.database.windows.net,1433;User ID=serveradmin;Password=********;MultipleActiveResultSets=False;Connect 
Timeout=30;Encrypt=True;TrustServerCertificate=False;Application Name="dbatools PowerShell module - dbatools.io"
VERBOSE: [10:54:19][Connect-DbaInstance] Connecting to Azure: source.database.windows.net
VERBOSE: [10:54:23][Connect-DbaInstance] Connecting to Data Source=TCP:destination.database.windows.net,1433;User ID=serveradmin;Password=********;MultipleActiveResultSets=False;Connect 
Timeout=30;Encrypt=True;TrustServerCertificate=False;Application Name="dbatools PowerShell module - dbatools.io"
VERBOSE: [10:54:24][Connect-DbaInstance] Connecting to Azure: destination.database.windows.net
VERBOSE: Performing the operation "Truncating table [dbo].[TPGGLBrowseTransStagingDBATools]" on target "[TCP:destination.database.windows.net,1433]".
VERBOSE: [10:54:26][Connect-DbaInstance] Connecting to Data Source=TCP:destination.database.windows.net,1433;User ID=serveradmin;Password=********;MultipleActiveResultSets=False;Connect 
Timeout=30;Encrypt=True;TrustServerCertificate=False;Application Name="dbatools PowerShell module - dbatools.io"
VERBOSE: [10:54:26][Connect-DbaInstance] Connecting to Azure: source.database.windows.net
VERBOSE: Performing the operation "Copy data from [dbo].[TPGGLBrowseTransStaging]" on target "[TCP:source.database.windows.net,1433]".
VERBOSE: Performing the operation "Writing rows to [dbo].[TPGGLBrowseTransStagingDBATools]" on target "[TCP:destination.database.windows.net,1433]".
WARNING: [10:54:28][Copy-DbaDbTableData] Something went wrong | Invalid object name 'dbo.TPGGLBrowseTransStaging'.

Stack Trace:

writeErrorStream      : True
PSMessageDetails      : 
Exception             : System.Exception: Invalid object name 'dbo.TPGGLBrowseTransStaging'. ---> System.Data.SqlClient.SqlException: Invalid object name 'dbo.TPGGLBrowseTransStaging'.
                           at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
                           at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
                           at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, 
                        TdsParserStateObject stateObj, Boolean& dataReady)
                           at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
                           at System.Data.SqlClient.SqlDataReader.get_MetaData()
                           at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean 
                        forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
                           at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, 
                        Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
                           at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 
                        completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
                           at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
                           at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
                           at System.Data.SqlClient.SqlCommand.ExecuteReader()
                           at CallSite.Target(Closure , CallSite , Object )
                           --- End of inner exception stack trace ---
TargetObject          : source.database.windows.net
CategoryInfo          : NotSpecified: (source.database.windows.net:PSObject) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Copy-DbaDbTableData,Stop-Function
ErrorDetails          : Invalid object name 'dbo.TPGGLBrowseTransStaging'.
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Stop-Function, C:\Users\admin_gb\Documents\WindowsPowerShell\Modules\dbatools\1.0.115\allcommands.ps1: line 83636
                        at Copy-DbaDbTableData<Process>, C:\Users\admin_gb\Documents\WindowsPowerShell\Modules\dbatools\1.0.115\allcommands.ps1: line 7217
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

Steps to Reproduce

Command I am running:

$SourceConnection = "source.database.windows.net"
$PasswordSource = ConvertTo-SecureString "sourcePW" -AsPlainText -Force
$AzureCredentialSource = New-Object System.Management.Automation.PSCredential("serveradmin"),$PasswordSource
$DestinationConnection = "destination.database.windows.net"
$PasswordDestination = ConvertTo-SecureString "destinationPW" -AsPlainText -Force
$AzureCredentialDestination = New-Object System.Management.Automation.PSCredential("serveradmin"),$PasswordDestination

$RunSettings = @{
    SqlInstance = $SourceConnection
    Destination = $DestinationConnection
    Database = 'ax_ods'
    DestinationDatabase = 'AX_ODS'
    Table = 'TPGGLBrowseTransStaging'
    DestinationTable = 'TPGGLBrowseTransStagingDBATools'
    Truncate = $true
    SqlCredential = $AzureCredentialSource
    DestinationSqlCredential = $AzureCredentialDestination
    Verbose = $true
}

Copy-DbaDbTableData @RunSettings

Expected Behavior

I expect the data in the source table to be copied to the destination table.

Actual Behavior

Errors out saying invalid object name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugs lifestaleStale Bot label used to identify issues that are no longer active and bot has closed them

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions