UPDATE sStudent.tAcademic Set ClassStatusId = null

UPDATE A SET ClassStatusId = 3
FROM sStudent.tAcademic A INNER JOIN sStudent.tStudentMaster  SM ON A.StudentId = SM.Id
INNER JOIN sStudent.tStudentAdmission SA ON A.StudentId = SA.StudentId AND A.ClassId = SA.LeftStandardId
WHERE SM.StatusId = 3

UPDATE sStudent.tAcademic SET ClassStatusId = 1 WHERE ClassStatusId is null
GO