none
The multi-part identifier could not be bound

    Question

  • I keep getting the following errors when I try run the following sql syntax

      

    SELECT WaybillNo FROM Scan WITH (NOLOCK) WHERE Scan.WaybillNo=WaybillHeader.WaybillNo AND WaybillHeader.ClientID=Scan.ClientID AND DocTypeID=1

    ERRORS:

    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "WaybillHeader.WaybillNo" could not be bound.
    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "WaybillHeader.ClientID" could not be bound.
    Msg 4104, Level 16, State 1, Line 1
    The multi-part identifier "WaybillNo.Scan" could not be bound.


    Friday, July 20, 2012 2:00 PM

Answers

  • Hello,

    In your from clause you only have the table "Scan", but no "WaybillHeader", therefore the columns of this unknown table can't be bound.

    Include the table into the from clause, e.g. as a join:

    SELECT WaybillNo 
    FROM Scan WITH (NOLOCK)
         INNER JOIN WaybillHeader
             ON Scan.WaybillNo=WaybillHeader.WaybillNo 
                AND WaybillHeader.ClientID=Scan.ClientID 
    WHERE  DocTypeID=1


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    Friday, July 20, 2012 2:06 PM
  • It should be:

    SELECT Scan.WaybillNo FROM Scan INNER JOIN WaybillHeader ON Scan.WaybillNo=WaybillHeader.WaybillNo 
    AND
    WaybillHeader.ClientID=Scan.ClientID 
    
    WHERE  WayBillHeader.DocTypeID=1 -- I assumed that this field came from WaybillHeader


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    Friday, July 20, 2012 2:45 PM
    Moderator

All replies

  • Hello,

    In your from clause you only have the table "Scan", but no "WaybillHeader", therefore the columns of this unknown table can't be bound.

    Include the table into the from clause, e.g. as a join:

    SELECT WaybillNo 
    FROM Scan WITH (NOLOCK)
         INNER JOIN WaybillHeader
             ON Scan.WaybillNo=WaybillHeader.WaybillNo 
                AND WaybillHeader.ClientID=Scan.ClientID 
    WHERE  DocTypeID=1


    Olaf Helper
    * cogito ergo sum * errare humanum est * quote erat demonstrandum *
    Wenn ich denke, ist das ein Fehler und das beweise ich täglich
    Blog Xing

    Friday, July 20, 2012 2:06 PM
  • you are missing joins to some tables WaybillHeader,waybillno 
    Friday, July 20, 2012 2:08 PM
  • It should be:

    SELECT Scan.WaybillNo FROM Scan INNER JOIN WaybillHeader ON Scan.WaybillNo=WaybillHeader.WaybillNo 
    AND
    WaybillHeader.ClientID=Scan.ClientID 
    
    WHERE  WayBillHeader.DocTypeID=1 -- I assumed that this field came from WaybillHeader


    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog

    Friday, July 20, 2012 2:45 PM
    Moderator