Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 SQL Server Administration (2005)
 Query Problem

Author  Topic 

peteoc
Starting Member

14 Posts

Posted - 2007-10-26 : 18:55:11
Hi,

I have 2 tables, MCCODES and MCTYPES. I want to update a field in MCCODES with a value from a field in MCTYPES based on a 3rd field.

My query is

UPDATE MCCODES SET D_MCTYPE2 = MCTYPES.id WHERE MCCODES.D_MCTYPE = MCTYPES.D_MCTYPE;

however I'm getting the error

The multi-part identifier "MCTYPES.D_MCTYPE" could not be bound.

I was hoping someone could shed some light on this as I'm clueless and near enough pulling out all my hair!!

Thanks in advance!

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-10-26 : 19:55:23
[code]
UPDATE MC
SET MC.D_MCTYPE2 = MT.id
FROM MCCODES MC
JOIN MCTYPES MT ON MC.D_MCTYPE = MT.D_MCTYPE
[/code]


Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page
   

- Advertisement -