| Author |
Topic |
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-31 : 01:42:38
|
| Hi friends,I am trying to add records from one table into another.SQLuse riqdb2INSERT INTO tblItemGrades (chrvItemGradeStaticComment,decItemGrade)SELECT chrvItem2StaticComment,decItem2GradeFROM tblItems2GOError msg/*------------------------use riqdb2INSERT tblItemGrades (chrvItemGradeStaticComment,decItemGrade)SELECT chrvItem2StaticComment,decItem2GradeFROM tblItems2GO------------------------*/Msg 515, Level 16, State 2, Line 2Cannot insert the value NULL into column 'ItemGradesID', table 'RIQDB2.dbo.tblItemGrades'; column does not allow nulls. INSERT fails.The statement has been terminated.Please advise how to insert new records - Is it because I havent set up Identity (1,1)????ThanksCm |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-31 : 01:49:14
|
| What you want to insert into Column ItemGradesID ???If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-31 : 01:52:20
|
| I do not want to insert into ItemGradesID, its the primary key. It is mentioned in the error msg |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-05-31 : 01:53:18
|
| If it is primary key, you should supply unique value to that column and you cant skip itMadhivananFailing to plan is Planning to fail |
 |
|
|
jen
Master Smack Fu Yak Hacker
4110 Posts |
Posted - 2006-05-31 : 01:54:43
|
you're probably confused about identity columns and primary key...you need to supply a value to the primary key column, unless it's an autogenerating one --------------------keeping it simple... |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-31 : 01:54:59
|
| or why are you not making it an identity column?If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-31 : 01:56:13
|
| how do I make it autogenerating????thanks |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-31 : 01:58:03
|
| I have just manually added values to the primary key so that it continues from ItemGradesID=1...to 55. Enough for my test insert. Still same error msg |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-05-31 : 02:00:19
|
| Just open the table in the EM and select the column and in the property section you will see Indenity, make the flag true and save the tableIf Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
Chopsmum
Starting Member
38 Posts |
Posted - 2006-05-31 : 02:04:01
|
| I think I know what the problem is. You cant add records to a new table when the ID conflicts. I have to either insert records as a value set or alternatively change the IDs of the original table so that the records can be added without conflict.Thanks anyway guys. Its never straight forward is it!!!Cm |
 |
|
|
|