Skip to content

Import-DbaCsv: Add -NoColumnOptimize switch#10195

Merged
potatoqualitee merged 1 commit intodataplat:developmentfrom
mbentham:development
Mar 5, 2026
Merged

Import-DbaCsv: Add -NoColumnOptimize switch#10195
potatoqualitee merged 1 commit intodataplat:developmentfrom
mbentham:development

Conversation

@mbentham
Copy link
Contributor

@mbentham mbentham commented Feb 27, 2026

Type of Change

  • Bug fix (non-breaking change, fixes # )
  • New feature (non-breaking change, adds functionality, fixes Import-DbaCsv: Add -NoColumnOptimize switch to skip post-import column shrinking #10194 )
  • Breaking change (affects multiple commands or functionality, fixes # )
  • Ran manual Pester test and has passed (Invoke-ManualPester)
  • Adding code coverage to existing functionality
  • Pester test is included
  • If new file reference added for test, has is been added to github.com/dataplat/appveyor-lab ?
  • Unit test is included
  • Documentation
  • Build system

Purpose

Allows optional skipping of the schema detection and column resize from NVARCHAR(MAX) after Import-DbaCsv has imported a file using -AutoCreateTable. Useful when importing multiple CSVs to the same table, as without a later CSV with a wider column than the first file would fail due to data truncation

Approach

  • Adds a -NoColumnOptimize switch to Import-DbaCsv that skips the automatic Optimize-ColumnSize step after -AutoCreateTable imports
  • Keeps columns at nvarchar(MAX) when the switch is set, allowing multiple CSV files to be imported into the same auto-created table without column truncation failures
  • Guards both call sites (transaction and no-transaction paths)

🤖 Generated with Claude Code

…n shrinking

When using -AutoCreateTable to import multiple CSV files into the same table,
the post-import Optimize-ColumnSize step shrinks nvarchar(MAX) columns to fit
the first file's data, causing subsequent imports to fail if later CSVs contain
longer values. The new -NoColumnOptimize switch skips this step, keeping columns
at nvarchar(MAX).

Tracks dataplat#10194

(do Import-DbaCsv)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@potatoqualitee potatoqualitee merged commit 861b0db into dataplat:development Mar 5, 2026
3 checks passed
@potatoqualitee
Copy link
Member

awsome, thank you 🙏🏼 will release your changes in a few days unless you need it faster.

@mbentham
Copy link
Contributor Author

mbentham commented Mar 5, 2026

No that's fantastic thanks. I'm just running an old version from before the auto-optimize was added for the affected process for now, few more days makes no difference

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.

Import-DbaCsv: Add -NoColumnOptimize switch to skip post-import column shrinking

2 participants