On this page
Why it happens
Error 515 means you tried to write a row that would put NULL into a column defined as NOT NULL. A NOT NULL column is a constraint that forces every row to carry a real value, so SQL Server rejects the statement and rolls it back rather than store a row with a missing required value.
The message names the exact column, table, and database: column 'email', table 'Shop.dbo.Customers'. That tells you precisely which required column was left empty. The error is severity 16, a normal, catchable constraint violation, not a server problem.
Common triggers are an INSERT that omits a required column that has no DEFAULT, passing an explicit NULL (or a variable that turned out NULL) into that column, or an UPDATE that sets a NOT NULL column to NULL. An INSERT ... SELECT whose source produces NULL for the column does the same thing.
Examples
INSERT that omits a required column
CREATE TABLE dbo.Customers (
id INT PRIMARY KEY,
name NVARCHAR(100) NOT NULL,
email NVARCHAR(255) NOT NULL
);
-- email is NOT NULL and has no default, but it is not supplied
INSERT INTO dbo.Customers (id, name) VALUES (1, 'Sara');
Msg 515, Level 16, State 2, Line 8 Cannot insert the value NULL into column 'email', table 'Shop.dbo.Customers'; column does not allow nulls. INSERT fails.
Passing an explicit NULL
INSERT INTO dbo.Customers (id, name, email)
VALUES (2, 'Ali', NULL);
Msg 515, Level 16, State 2, Line 1 Cannot insert the value NULL into column 'email', table 'Shop.dbo.Customers'; column does not allow nulls. INSERT fails.
An UPDATE that clears a required column
-- Setting a NOT NULL column back to NULL is also rejected.
UPDATE dbo.Customers SET email = NULL WHERE id = 1;
Msg 515, Level 16, State 2, Line 2 Cannot insert the value NULL into column 'email', table 'Shop.dbo.Customers'; column does not allow nulls. UPDATE fails.
How to fix it
Supply a value for the required column
The direct fix is to provide a real value for the NOT NULL column in the INSERT or UPDATE. This is correct whenever the column is genuinely required.
INSERT INTO dbo.Customers (id, name, email)
VALUES (1, 'Sara', 'sara@example.com');
Add a DEFAULT so omitted inserts get a value
If there is a sensible fallback, add a DEFAULT constraint. Then an INSERT that omits the column is filled with the default instead of failing.
ALTER TABLE dbo.Customers
ADD CONSTRAINT DF_Customers_email
DEFAULT 'unknown@example.com' FOR email;
-- Now this succeeds and email becomes the default
INSERT INTO dbo.Customers (id, name) VALUES (1, 'Sara');
Substitute a default in the source with COALESCE
When the value comes from a SELECT that can produce NULL, wrap it in COALESCE to fall back to a non-NULL value before it reaches the column.
INSERT INTO dbo.Customers (id, name, email)
SELECT id, name, COALESCE(email, 'unknown@example.com')
FROM staging.Customers;
Allow NULLs if the column is truly optional
If the column should not be required after all, relax the constraint so it accepts NULL. Only do this when a missing value is genuinely valid.
ALTER TABLE dbo.Customers
ALTER COLUMN email NVARCHAR(255) NULL;
How to prevent it
Define DEFAULT constraints for required columns that have a sensible fallback, so an omitted value never becomes NULL. This removes the most common cause of 515 outright.
Validate required fields in the application before you submit the INSERT, and never pass an unvalidated variable straight into a NOT NULL column. When loading data, use COALESCE to replace NULLs in the source. For details on how these rules work, see the constraints guide.
Common questions
How do I fix SQL Server error 515?
Provide a value for the column named in the message. Either include it in the INSERT or UPDATE, add a DEFAULT constraint so omitted inserts get a value, use COALESCE to replace NULLs coming from a SELECT, or, if the column is truly optional, alter it to allow NULLs. The message names the exact column and table to fix.
Which column caused error 515?
The message tells you directly. It names the column, table, and database, for example column 'email', table 'Shop.dbo.Customers'. That column is defined as NOT NULL and received no value, so check that your statement supplies one.
Why does error 515 happen when I did not mention the column?
If you omit a NOT NULL column from an INSERT and it has no DEFAULT constraint, SQL Server tries to store NULL in it and fails. Either list the column with a value or add a DEFAULT so omitted inserts get a sensible value.