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)
its giving me error: The multi-part identifier "hsm.hotelid" could not be bound.
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)
its giving me error: The multi-part identifier "hsm.hotelid" could not be bound.
Correction, you need to use the alias as the UPDATE table:
UPDATE hsm
SET....
FROM HotelSourceMap AS hsm
....
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.