Ambigous table name, but can''t work out ambiguity

  • I have the following query, which when run returns that DimSalesrep (on the UPDATE line) is ambiguous. I know I've included it a few times but I've aliased it everywhere else. I've tried qualifying the name of the table as well, back to the database level. Any ideas?

    -----------

    UPDATE DimSalesRep

    SET DimSalesRep.national_manager_id = DSR3.salesrep_id

    FROM DimSalesrep Mgr LEFT OUTER JOIN DimSalesrep DSR2

    ON Mgr.manager_id = DSR2.salesrep_id LEFT OUTER JOIN MudgeeLiv_App.dbo.dept dept

    ON DSR2.department = dept.dept LEFT OUTER JOIN DimSalesrep DSR3

    ON LTRIM(RTRIM(dept.mgr_num)) = LTRIM(RTRIM(DSR3.code))

    GO

  • UPDATE Mgr

    SET national_manager_id = DSR3.salesrep_id

    FROM DimSalesrep Mgr

    LEFT OUTER JOIN DimSalesrep DSR2 ON Mgr.manager_id = DSR2.salesrep_id

    LEFT OUTER JOIN MudgeeLiv_App.dbo.dept dept ON DSR2.department = dept.dept

    LEFT OUTER JOIN DimSalesrep DSR3 ON LTRIM(RTRIM(dept.mgr_num)) = LTRIM(RTRIM(DSR3.code))

  • Thanks, worked a treat. Makes sense when you think about it

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply