Skip to content
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

[Bug] Get-DbaLastGoodCheckDb fails on Database names with non standard characters #5585

Closed
3 tasks done
sqllensman opened this issue May 24, 2019 · 0 comments · Fixed by #5586
Closed
3 tasks done
Assignees

Comments

@sqllensman
Copy link
Contributor

Before submitting a bug report:

Collect output of following command and paste below:

PSVersion 5.1.18362.113
dbattools 0.9.831

  • Running latest release of dbatools
  • Verified errors are not related to permissions
  • Is this bug with Copy-DbaDatabase? You can replicate it using Backup-DbaDatabase ... | Restore-DbaDatabase ...

NOTE: Copy-DbaDatabase will not work in every environment and every situation. Instead, we try to ensure Backup & Restore work in your environment.

Environmental data

Name Value


PSVersion 5.1.18362.113
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.18362.113
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

SQL Server:

Microsoft SQL Server 2017 (RTM-CU14-GDR) (KB4494352) - 14.0.3103.1 (X64) Mar 22 2019 22:33:11 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows 10 Pro 10.0 (Build 18362: ) (Hypervisor)


<!-- NOTE: If the above information is not provided as a minimum your issue will not be acknowledged -->

## Errors Received

Exception calling "ExecuteWithResults" with "1" argument(s): "Execute with results failed for 
Database NameWith]'. "
At C:\Program Files\WindowsPowerShell\Modules\dbatools\0.9.831\allcommands.ps1:42189 char:17
+                 $resultTable = $db.ExecuteWithResults($sql).Tables[0]
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FailedOperationException

Steps to Reproduce

Get-DbaLastGoodCheckDb -SqlInstance ServerName -Database NameWith]

Expected Behavior

Should return table with LastGoodCheckDB results

Actual Behavior

Throws error as cannot handle databases that include characters that need to be escaped.

Cause

This is caused because the line in code that creates the T-SQL script
Line 117 - $sql = "DBCC DBINFO ([$($db.name)]) WITH TABLERESULTS"

does not properly escape any embedded ] characters

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 a pull request may close this issue.

1 participant