metricsign
Start free
Medium severitydata integrity

Power BI Refresh Error:
515

What does this error mean?

An INSERT or UPDATE attempted to place a NULL value into a column defined as NOT NULL.

Common causes

  • 1Source data has NULL in a column that the target schema requires as NOT NULL
  • 2ADF column mapping is missing — a required column is unmapped and defaults to NULL
  • 3A new NOT NULL column was added to the target table without a default value and old pipelines don't provide it

How to fix it

  1. 1Step 1: Identify the column from the error message. Verify it is NOT NULL: SELECT COLUMN_NAME, IS_NULLABLE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MyTable' AND COLUMN_NAME = 'col';
  2. 2Step 2: In ADF, add an explicit column mapping and use a Derived Column transformation to replace NULL with a default value: iif(isNull(col), 'default', col).
  3. 3Step 3: Add a default constraint to the column to handle NULLs from old pipelines: ALTER TABLE [table] ADD CONSTRAINT [DF_col] DEFAULT ('unknown') FOR [col];

Frequently asked questions

How do I find all NOT NULL columns in a table?

Run: SELECT COLUMN_NAME, DATA_TYPE FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'MyTable' AND IS_NULLABLE = 'NO';

Can I add a DEFAULT constraint to an existing NOT NULL column?

Yes — adding a DEFAULT constraint does not change existing rows. New rows that don't provide the column value will use the default: ALTER TABLE [table] ADD CONSTRAINT [DF_col] DEFAULT (0) FOR [col];

Does dbt handle NOT NULL constraints?

dbt can test for not_null in schema.yml, but it does not enforce constraints in SQL Server automatically. The constraint enforcement happens at the database level when dbt runs INSERT or CREATE TABLE AS SELECT statements.

Official documentation: https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-515-database-engine-error

Other data integrity errors