Skip to content

Import-DbaCsv Regression: Null column headers no longer auto-renamed during import #39

@late-chapter-lived

Description

@late-chapter-lived

Verified issue does not already exist?

I have searched and found no existing issue

What error did you receive?

When an empty header was encountered by the LumenWorks library, it generated a column name in the form Column#, where # was the index of the column. The updated version with new library does not appear to offer this functionality and therefore throws the following exception:

Exception calling "ExecuteNonQuery" with "0" argument(s): "An object or column name is missing or empty. For SELECT INTO statements, verify each column has a name. For other statements, look for empty alias names. Aliases defined as "" or [] are not allowed. Change the alias to a valid name."

Thankfully the exception is descriptive.

Steps to Reproduce

@'
,ValidHeader
Value1,Value2
'@ | Set-Content -Path .\test.csv

$importParams = @{
  Path            = '.\test.csv'
  SqlInstance     = $server
  Database        = $db
  Table           = 'TestNullHeader'
  AutoCreateTable = $true
  KeepNulls       = $true
  EnableException = $true
}
Import-DbaCsv @importParams

Please confirm that you are running the most recent version of dbatools

2.7.13

Other details or mentions

No response

What PowerShell host was used when producing this error

PowerShell Core (pwsh.exe)

PowerShell Host Version

Name Value


PSVersion 7.5.4
PSEdition Core
GitCommitId 7.5.4
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0

SQL Server Edition and Build number

Microsoft SQL Server 2022 (RTM-GDR) (KB5068407) - 16.0.1160.1 (X64) Oct 3 2025 18:06:58 Copyright (C) 2022 Microsoft Corporation Standard Edition (64-bit) on Windows Server 2025 Datacenter Azure Edition 10.0 (Build 26100: ) (Hypervisor)

.NET Framework Version

.NET 9.0.10

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