• There is no reason for the cursor. Try a joined UPDATE to get less code and much better performance:

    UPDATE t SET

    t.Code = md.Code,

    t.GPOName = md.GPONam,

    t.TotalMO = md.TotalMO

    FROM tempDailyUPD

    JOIN

    (

    select

    distinct(masterdata.gpo_id) as Code,

    gpo.name as GPOName,

    count(masterdata.mno) as TotalMO

    from masterdata, gpo

    where masterdata.gpo_id = gpo.gpo_id

    group by masterdata.gpo_id, gpo.name

    ) md

    ON t.[Your Destination JOIN Column] = md..[Your Source JOIN Column]

    Notice the ON part of the JOIN. Here you have to define the relation between both tables which seems to be missing in your script.

    Flo