August 4, 2005 at 1:47 am
Hi, Can someone help with the following problem please (SQL Server 2000)
I have two tables
tblStudent
StudentID int,
RollStatus int
tblStudentOld
StudentID int
Boarder int
The StudentIDs match in each table (unique key).
I need to use the Old version of the table to update the other table where the student IDs match eg...
I need to pick up the Boarder value from the tblStudentOld table then insert 315 in the RollStatus column of tblstudent if this is a 1 in the Boarder column, or 316 if it is 0 in the Boarder colun. If the Old table contains a null, I need to update with a null.
Any suggestions.
Many thanks.
CCB
August 4, 2005 at 2:51 am
If those are the only values in tblStudentOld, how about
update tblStudent
set RollStatus = 316 - o.Boarder
from tblStudent s
join tblStudentOld o
on o.StudentID = s.StudentID
August 4, 2005 at 6:07 am
Thanks, I'll give that a go.
CCB
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply