Skip to content

Issue4106#4231

Merged
potatoqualitee merged 10 commits intodataplat:developmentfrom
sqllensman:Issue4106
Oct 17, 2018
Merged

Issue4106#4231
potatoqualitee merged 10 commits intodataplat:developmentfrom
sqllensman:Issue4106

Conversation

@sqllensman
Copy link
Copy Markdown
Contributor

Type of Change

Purpose

Fix issues in Copy-DbaDbTableData

  1. Fixing issues with Schema's not being honoured
  2. Fixing issues with same table existing in multiple schema
  3. Fixing issues with table being copied onto itself

Commands to test

Copy-DbaDbTableData

@sqllensman
Copy link
Copy Markdown
Contributor Author

Code will not allow a table to be copied into itself (especially with Truncate option as this would actually just be truncating the table. Tests required some modification to
(1) Update test that was doing this
(2) Include test for this behaviour

@potatoqualitee
Copy link
Copy Markdown
Member

Thanks so much! To confirm, this is not a breaking change? I saw the docs update from three part to two part.

@sqllensman
Copy link
Copy Markdown
Contributor Author

The "change" to two-part is actually just clarification of how command works and not a change in functionality. The use of three part names is not really supported by the code

In the current code there is a test at line 211 to require a Database when using a SqlInstance rather than piped input.

To resolve the Table there is a call at line 230 to
Get-DbaDbTable -SqlInstance $server -Table $Table -Database $Database

A three-part name can be passed but the database name in table must be same as the Database parameter. Using something like Database AdventureWorks2014 and Table AdventureWorks2014.[dbo].[DatabaseLog] will still work but the Database part of the Tablename does not add any value.
A call with something like
-Database AdventureWorks2014 -Table AdventureWorks2016.[dbo].[DatabaseLog]
will cause an error of table not found.

Strictly there is functionality change as
(a) It will not allow copying a table into itself
(b) If a table exists in multiple schemas and the Schema name is not included it will not "guess" and pick first table found.

However, I think both of these were Bugs and not intended features.

@potatoqualitee potatoqualitee merged commit 78fbd0f into dataplat:development Oct 17, 2018
@potatoqualitee
Copy link
Copy Markdown
Member

excellent, thank you for the explanation! merged and should be in master soon.

@sqllensman sqllensman deleted the Issue4106 branch October 22, 2018 06:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copy-DbaDbTableData doesn't copy to correct table if >1 table with same name in different schemas

2 participants