March 5, 2009 at 5:38 pm
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.
March 5, 2009 at 6:21 pm
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
March 5, 2009 at 7:29 pm
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