UPDATE d
SET Preparation =
    CASE
        WHEN d.CTrn IS NOT NULL
        THEN ISNULL(c.NameRus + ' ', '')
        ELSE ISNULL(m.NameRus + ' ', '')
    END +
    CASE WHEN mf.Name IS NOT NULL AND mf.Name <> '' THEN LTRIM(RTRIM(mf.Name)) + ' ' ELSE '' END +
    LTRIM(RTRIM(dv.Value))
FROM RDS.T_DRUG_APPLICATION_LIST_ITEM d
LEFT JOIN PHARM.T_C_TRN c ON d.CTrn = c.CTrnID
LEFT JOIN PHARM.T_C_MNN m ON d.CMnn = m.CMnnID
LEFT JOIN PHARM.T_MEDICATION_FORMS mf ON d.MedicationForms = mf.MedicationFormsID
LEFT JOIN RDS.S_DLO_DoseView dv ON d.DoseView = dv.Id
WHERE d.Preparation IS NULL
   OR LTRIM(RTRIM(d.Preparation)) = '';
