High severitydata loading
Power BI Refresh Error:
COPY INTO Column Count Mismatch
What does this error mean?
A COPY INTO command failed because the number of columns in the source file does not match the number of columns in the target table (or the explicit column list provided).
Common causes
- 1Source CSV or Parquet file has more or fewer columns than the target table
- 2Column list in the COPY INTO statement does not match the file's field count
- 3Schema of the target table was changed (column added or dropped) without updating the file format or pipeline
- 4File generated with a different delimiter or quoting that causes incorrect column parsing
- 5Using a named file format with an outdated SKIP_HEADER setting that misaligns column positions
How to fix it
- 1Run `SELECT $1,$2,... FROM @stage/file.csv (FILE_FORMAT => ...)` to count the actual columns in the file
- 2Compare with `DESCRIBE TABLE <table>` to find the mismatch
- 3If the file has extra columns, use a column mapping in COPY INTO: `COPY INTO t (col1, col2) FROM (SELECT $1, $3 FROM @stage/file.csv)`
- 4If the table has extra columns, add DEFAULT values or allow NULLs for the missing file columns
- 5Update the pipeline to regenerate files with the correct schema after any table schema change