开发者

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
....
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜