MSSQLMSSQL 515

MSSQL 515: Cannot Insert NULL into Column

SQL Server error 515 is raised when an INSERT or UPDATE tries to place NULL into a column that has a NOT NULL constraint and no default value defined.

Example Query

CREATE TABLE orders (order_date DATETIME NOT NULL);
INSERT INTO orders (order_date) VALUES (NULL);

Common Causes

  1. 1Required column omitted from INSERT with no DEFAULT constraint
  2. 2Application explicitly passing NULL for a mandatory field
  3. 3Bulk insert with incomplete source data

How to Fix It

Supply a value for every NOT NULL column. Add a DEFAULT constraint: order_date DATETIME NOT NULL DEFAULT GETDATE(). Use COALESCE in the INSERT to substitute NULLs with defaults.

Need a reliable database?

Try Supabase — free PostgreSQL with a generous free tier. No credit card required.

Get started free →

Got a query causing this error?

Paste it into SQLbuddy and get an instant plain-English explanation with optimization tips.

Analyze My Query →