January 28, 2011 at 11:38 am
When I run the following statement, I receive the error message: Cannot insert the value NULL into column 'PK'"
Insert Into ComTrace (Div,Stag)
Select Distinct Div,Stag
From RefVal;
Understand why but not sure how to resolve it. Any suggestions?
January 28, 2011 at 11:56 am
Probably you have NULLs in RefVal.Div. Maybe you could add
WHERE RefVal.Div is not NULL
Edit: I was mistakenly thinking 'Div' was a primary key.
January 28, 2011 at 12:30 pm
I do not have NULL value. The PK value is set to auto increment and since I am not passing the PK value, its returning the error. The question is when insert is taking place, I'd like PK value to generate automatically instead of having to hard code it.
January 28, 2011 at 12:39 pm
Looks ok to me.
Double check it's set to auto increment, and not just set to not allow nulls.
January 28, 2011 at 1:08 pm
I made a mistake. It appears the Identity Specification is set to no. The PK column, however, does not allow NULL. Is there a way to generate PK value automatically when those two values (Div column and Stag Column) are being inserted?
January 28, 2011 at 1:30 pm
Obvious way is to set identity=yes. Otherwise I think you would have to write code to maintain the values. Maybe there's another way ?
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply