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?
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