New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write-DbaDataTable "Schema does not exist" issue #1845

Closed
BartekR opened this Issue Jul 23, 2017 · 2 comments

Comments

Projects
None yet
4 participants
@BartekR
Contributor

BartekR commented Jul 23, 2017

Bug Report

General Troubleshooting steps

  • Verified running latest release of dbatools? (0.9.15)
  • Verified errors are not related to permissions? (using sa account)
  • Can duplicate in new/fresh PowerShell.exe session?

Version Information

  • Operating System Windows 10 Home, v 1703, compilation 15063.483
  • PowerShell Version: 5.1
  • SQL Server for Linux RC1, CTP 2.1

Steps to Reproduce

  1. Ensure that schema name does exist in target database but not in master database
  2. Run any command that inserts data using Write-DbaDataTable to table in target database in target schema
  3. Get the error "Schema does not exist"
  4. Create schema also in master database
  5. Problem disapears.
  6. Drop schema in master database
  7. It still works OK for tempdb, stops working for user database
  8. If working with tempdb - drop schema in master database , restart server, create schema in tempdb database, run Write-OutDbaDataTable again - "Schema does not exist"

The problem verified with tempdb database as well as user database. Tested with parameters:
-Table userdb.userschema.usertable
-Database userdb -Schema userschema -Table usertable

Sample code (works after schema imnotinmaster is created in tempdb):

 $cred = Get-Credential sa
 Get-Process -Name powershell* | Out-DbaDataTable | Write-DbaDataTable -SqlInstance 127.0.0.1:14333 -SqlCredential $cred -Table tempdb.imnotinmaster.PowerShellProcesses -AutoCreateTable 

Probably the error with schema checking, line 399:
if($schema -notin $server.Databases[0].Schemas.Name)

Should be (?):
if($schema -notin $server.Databases[$Database].Schemas.Name)

  • Attach any screenshots (if possible/allowed)
    write-dbadatatable_error
  • Attach logs generated by dbatools (Get-DbatoolsLog)
23.07.2017 10:52:28 Out-DbaDataTable   Debug                        Bound parameters:                                                          
23.07.2017 10:52:28 Out-DbaDataTable   Debug                        TimeSpanType = TotalMilliseconds | SizeType = Int64                        
23.07.2017 10:52:28 Write-DbaDataTable VeryVerbose     MSSQLSERVER  Connecting to 127.0.0.1,14333                                              
23.07.2017 10:52:28 Out-DbaDataTable   InternalComment              Finished                                                                   
23.07.2017 10:52:28 Write-DbaDataTable Warning                      Schema does not exist                                                      

@potatoqualitee

This comment has been minimized.

Show comment
Hide comment
@potatoqualitee

potatoqualitee Jul 23, 2017

Member

loving that sql server for linux! what what!

Thanks for this report! I'll assign it and hopefully we can get this resolved this week.

Member

potatoqualitee commented Jul 23, 2017

loving that sql server for linux! what what!

Thanks for this report! I'll assign it and hopefully we can get this resolved this week.

@ClaudioESSilva

This comment has been minimized.

Show comment
Hide comment
@ClaudioESSilva

ClaudioESSilva Dec 13, 2017

Collaborator

This was fixed here -> 00fffb2#diff-263662ad62ba0ca6b00ef913b20569a8 by @burnbay
Can be closed.

Collaborator

ClaudioESSilva commented Dec 13, 2017

This was fixed here -> 00fffb2#diff-263662ad62ba0ca6b00ef913b20569a8 by @burnbay
Can be closed.

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