What is the error in this update query?
UPDATE HotelSourceMap
SET hsm.hotelid = co.hotelid
FROM HotelSourceMap AS hsm
JOIN hotels AS co
ON (hsm.hotelname= co.[name]
AND hsm.cityid = co.cityid)
It's giving me error: The multi-part identifier "hsm.hotelid" could not be bound.开发者_运维技巧
Assuming the field hotelid exists in the table try changing:
UPDATE HotelSourceMap SET hsm.hotelid ...
to
UPDATE HotelSourceMap hsm SET hsm.hotelid ...
or alternatively
UPDATE HotelSourceMap SET hotelid ...
Try this :-
UPDATE
hsm
SET
hotelid = co.hotelid
FROM
HotelSourceMap hsm,
Hotels co
WHERE
hsm.hotelname= co.[name] AND hsm.cityid = co.cityid
In your main statement, you say you want to update HotelSourceMap.
In your SET, you try to update a field belonging to a logically different entity, hsm.
Correction, you need to use the alias as the UPDATE table:
UPDATE hsm
SET....
FROM HotelSourceMap AS hsm
....
精彩评论