none
T-SQL: Update Statement; Problem with "unbound field"

    Question

  • I'm having a problem with getting the SLCT.udCompCodeCategory (which is a valid field in the SLCT table to bind in the code below. 

    Any help would be appreciated.

    Thanks,

    ...bob sutor

    Error Message:

    Msg 4104, Level 16, State 1, Line 15

    The multi-part identifier "SLCT.udCompCodeCategory" could not be bound.

    Offending Code:

    BEGIN

    UPDATE dbo.bSLCT

    SET SLCT.udCompCodeCategory = bHQCP.udComplianceCategory

    FROM bSLCT INNER JOIN bHQCP ON bSLCT.CompCode = bHQCP.CompCode

    WHERE bSLCT.SLCo = 100 --FOR TESTING ONLY END


    Bob Sutor

    Saturday, June 29, 2013 10:39 PM

Answers

  • Do not qualify the column names on the left side of the = sign in the SET clause.  It's not needed (you already specified you were updating the table dbo.bSLCT in the UPDATE clause, and it's illegal).  So you want

    UPDATE dbo.bSLCT
    SET udCompCodeCategory = bHQCP.udComplianceCategory
    FROM bSLCT INNER JOIN bHQCP ON bSLCT.CompCode = bHQCP.CompCode
    WHERE bSLCT.SLCo = 100 --FOR TESTING ONLY END

    Tom

    • Proposed as answer by Naomi NModerator Sunday, June 30, 2013 4:21 AM
    • Marked as answer by ConstPM Thursday, July 04, 2013 7:16 PM
    Sunday, June 30, 2013 2:17 AM

All replies

  • Do not qualify the column names on the left side of the = sign in the SET clause.  It's not needed (you already specified you were updating the table dbo.bSLCT in the UPDATE clause, and it's illegal).  So you want

    UPDATE dbo.bSLCT
    SET udCompCodeCategory = bHQCP.udComplianceCategory
    FROM bSLCT INNER JOIN bHQCP ON bSLCT.CompCode = bHQCP.CompCode
    WHERE bSLCT.SLCo = 100 --FOR TESTING ONLY END

    Tom

    • Proposed as answer by Naomi NModerator Sunday, June 30, 2013 4:21 AM
    • Marked as answer by ConstPM Thursday, July 04, 2013 7:16 PM
    Sunday, June 30, 2013 2:17 AM
  • Thanks.  That worked.


    Bob Sutor

    Thursday, July 04, 2013 7:16 PM