UPDATE [ECS_AccountAllocationSettings]
SET PeriodDate = (SELECT DISTINCT PeriodDate
FROM ECS_Period_Check
WHERE PeriodDate = variable),
Period = (SELECT DISTINCT Period
FROM ECS_Period_Check
WHERE PeriodDate = variable),
Debit = (SELECT DISTINCT Debit
FROM ECS_Period_Check
WHERE PeriodDate = variable),
Credit = (SELECT DISTINCT Credit
FROM ECS_Period_Check
WHERE PeriodDate = variable)
FROM [ECS_AccountAllocationSettings]
WHERE Substring(MainAccount, 1, 4) = variable