DElete from [sHrm].[tExaminationCustomColumns]
where ColumnName not in (select Code from sOrderEntry.tTestParameterMaster) and ColumnName not in (select Title from sExamination.tGeneralTemplateParameter) and (ColumnType =3 or ColumnType =4) 
Go

DElete from sExamination.tOPDCustomColumns
where ColumnName not in (select Code from sOrderEntry.tTestParameterMaster) and ColumnName not in (select Title from sExamination.tGeneralTemplateParameter) and (ColumnType =3) 
or (ColumnType =10) or (ColumnType =11)