Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SQL insert column does not allow nulls. INSERT fails

0 views
Skip to first unread message

suncity...@gmail.com

unread,
Dec 3, 2007, 6:32:03 PM12/3/07
to
This is driving me nuts.

I'm trying to update TABLE_A based on values found in TABLE_B, which
has an identical structure.

Greatly simplified, here's my statement:

INSERT INTO table_A (value_1, value_2, value3,... valueN)
SELECT value_1, value_2, value3,... valueN
FROM table_B
WHERE value_1 = 50

This doesn't work -- the message:
Server: Msg 515, Level 16, State 2, Line 2
Cannot insert the value NULL into column 'value_3', table
'foo.dbo.table_A'; column does not allow nulls. INSERT fails.
The statement has been terminated.

'Value_3' in Table_B is populated with non-null data (value 'N'). The
field is (char(1), Not Null). It's not trying to insert a NULL value..
or it shouldn't be.. so, why isn't it inserting?

If I try using a INSERT INTO .. VALUES statement and provide the
explicit values, the insert works. It just doesn't seem to work with
SELECT.

Any ideas?

Alejandro Mesa

unread,
Dec 3, 2007, 8:11:01 PM12/3/07
to
suncity...@gmail.com,

What is the result of:

INSERT INTO table_A (value_1, value_2, value3,... valueN)
SELECT value_1, value_2, value3,... valueN
FROM table_B

WHERE value_1 = 50 and value3 IS NOT NULL


AMB

0 new messages