Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
jpost
Starting Member
43 Posts |
Posted - 2012-10-16 : 09:45:41
|
I am trying to update values in a table called POS from a temp table that I created. I want to update the eligibility field in the POS table with the value in the status column from the temp table.I have to join the temp table with the student table because there isn't a student number listed in the POS table. Here is my code:INSERT INTO POSEligibility (eligibility)select tt.StatusFROM TempTestTable ttjoin Student s on tt.StudentID = s.studentNumberjoin POSEligibility pe on s.personID = pe.personIDWhen I run this code I get the error that statesCannot insert the value NULL into column 'personID', table 'pickerington_sandbox.dbo.POSEligibility'; column does not allow nulls. INSERT fails.The statement has been terminated.I added a where clause to narrow my insert down to just one student and still got the same error. Any suggestions? |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-10-16 : 09:53:20
|
you told update and what you gave is an insert codeas per your explanation it should beUPDATE pSET p.eligibility= t.StatusFROM POSEligibility pInner join Student s ON s.personID = p.personIDINNER JOIN temptesttable ton t.StudentID = s.studentNumber ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|