
update c
set c.SchoolContacts_SchoolContacts_Subjectifapplicable = subj.itemID
from [Framework_INDE-2_Demo].[dbo].[publ_SchoolContacts] as c
left join publ_SubjectManagement subj 
on subj.Subjects_SubjectDetails_SubjectName = c.SchoolContacts_SchoolContacts_Subjectifapplicable;

update pal_SurfaceField
set relationalFields = 'Subjects_SubjectDetails_SubjectName', 
relationalObject = 'publ_SubjectManagement',
isCustomSource = 1,
relationalValues = 'itemID',
surfaceFieldTypeId = 30
where recId = 495
and surfaceFieldName = 'SchoolContacts_SchoolContacts_Subjectifapplicable';