views:

39

answers:

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

A: 

Correction, you need to use the alias as the UPDATE table:

UPDATE hsm
SET....
FROM HotelSourceMap AS hsm
....
AdaTheDev
no it is their...
Rajesh Rolen- DotNet Developer
hotelid field exist in Hotelsourcemap table...
Rajesh Rolen- DotNet Developer
+3  A: 

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 ...
Paolo
wow..exactly what i want... its working gr8....UPDATE hsmSET hsm.hotelid = co.hotelid FROM HotelSourceMap AS hsm JOIN hotels AS co ON hsm.hotelname= co.[name] AND hsm.cityid = co.cityid
Rajesh Rolen- DotNet Developer
+1  A: 

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.

Paul Alan Taylor
Thanks a lot its working but please tell tell me what is error in my query..
Rajesh Rolen- DotNet Developer
Answered query. Let me know if you need any more clarification.
Paul Alan Taylor