
update peisdb.[dbo].[Exam_Result] set TextResult=tt.TextResult
from
(
	select t.id,t2.TextResult from peisdb.dbo.Exam_Result t  
	left join 
	( 
			SELECT
				C.ID AS PID,C.DeptName,
				D.FeeItemId AS FID,D.Name AS FeeItemName,A.NAME AS RptItemName,
				A.TextValue AS TextResult,ItemClass='检查',A.PacsVerifyOperName AS Reporter, 	A.PacsVerifyOperDate AS ReportTime
			FROM PEIS.DBO.EnrollmentApplicationSheet A
			LEFT JOIN PEIS.DBO.DEPARTMENT B ON A.DepartmentId=B.ID
			LEFT JOIN Exam_Part C ON A.EnrollmentId=C.EID AND B.HISCODE=C.DeptCode AND B.NAME=C.DeptName
			LEFT JOIN PEIS.DBO.EnrollmentApplicationSheetFeeItem D ON A.ID=D.EnrollmentApplicationSheetId
			WHERE A. TextValue IS NOT NULL
							
			) as t2  on t2.pid=t.pid and t2. RptItemName	=t.RptItemName and t2.FeeItemName=t.FeeItemName 
			where (t.TextResult is null or t.TextResult='')and (t2.TextResult <>'') 
) tt
where Exam_Result.id=tt.id  
 
 