Skip to content
Advertisement

Cannot insert the value NULL into column

I’m having some problems. I am trying to get a table to update, however it is not updating because one of the fields contains rows with a NULL value.

Heres the original query which gives no error:

Now, the nextUpdate column might be NULL, so I am trying to accommodate for that with this query:

You can see I’ve added “OR nextUpdate IS NULL” in brackets with the other condition for nextUpdate.

However, I am getting an error “Cannot insert the value NULL into column ‘quantityLimit’, table ‘myname.dbo.EmpPac’; column does not allow nulls. UPDATE fails.”

This makes no sense to me as, when viewing myLittleAdmin, shows me a NULL value for some rows in that table column.

Advertisement

Answer

Adding OR nextUpdate IS NULL to your WHERE clause widens the search criteria – i.e. more rows can be found.

Apparently, one of these additional rows has a NULL in allocation field (which then gets assigned to quantityLimit which, according to the error message, is NOT NULL).

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement