The multi-part identifier could not be bound.

  • Hi All,

    iam newbie,

    IF EXISTS (SELECT RoomID,DateWhenFilled,DateWhenFree,TimeForHouseKeeping

    FROM HouseKeeping)

    UPDATE HouseKeeping

    SET DateWhenFilled=PresidentialSuite.DateWhenFilled,

    DateWhenFree=PresidentialSuite.DateWhenFree,

    TimeForHouseKeeping=PresidentialSuite.TimeForHouseKeeping

    where (HouseKeeping.RoomID = PresidentialSuite.RoomID

    and PresidentialSuite.Available='no')

    ELSE

    INSERT INTO HouseKeeping (RoomID,DateWhenFilled,DateWhenFree,TimeForHouseKeeping)

    select PresidentialSuite.RoomID,PresidentialSuite.DateWhenFilled,PresidentialSuite.DateWhenFree,PresidentialSuite.TimeForHouseKeeping

    from PresidentialSuite

    where PresidentialSuite.Available='no';

    iam getting this error:

    Msg 4104, Level 16, State 1, Line 4

    The multi-part identifier "PresidentialSuite.RoomID" could not be bound.

    Msg 4104, Level 16, State 1, Line 4

    The multi-part identifier "PresidentialSuite.Available" could not be bound.

    and if i add braces to 'select' statement , iam getting following error:

    Msg 102, Level 15, State 1, Line 14

    Incorrect syntax near ','.

    may be the solution is simple but iam unable to figure it out.

    thanks in advance.

  • just a syntax error...you left out the FROM! if you are going to update one table from another, you have to include that table in the from statement:

    UPDATE HouseKeeping

    SET DateWhenFilled=PresidentialSuite.DateWhenFilled,

    DateWhenFree=PresidentialSuite.DateWhenFree,

    TimeForHouseKeeping=PresidentialSuite.TimeForHouseKeeping

    FROM PresidentialSuite

    where (HouseKeeping.RoomID = PresidentialSuite.RoomID

    and PresidentialSuite.Available='no')

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • thanks alot

    its solved

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

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