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 2008 Forums
 Transact-SQL (2008)
 Update from another table

Author  Topic 

Steve2106
Posting Yak Master

183 Posts

Posted - 2015-01-06 : 09:23:55
Hi There,

I am trying to update a field based on a matching value from another table. I have tried the query below but I keep getting "The multi-part identifier "m.StatusID" could not be bound."

Query:
UPDATE
tbMAdd
SET
m.StatusID = as.StatusID
FROM
tbMAdd m
INNER JOIN
tbAddStatus as
ON
m.AutoId = as.AddID

Thanks for your help.

Best Regards,


Always Learning.

Ifor
Aged Yak Warrior

700 Posts

Posted - 2015-01-06 : 09:29:24
[code]
UPDATE m
SET StatusID = as.StatusID
...
[/code]
Go to Top of Page

sz1
Aged Yak Warrior

555 Posts

Posted - 2015-01-06 : 10:55:14
You cant use as as alias as its built in function: try this


UPDATE
tbMAdd
SET
[m.StatusID] = [a.StatusID]
FROM
tbMAdd m
INNER JOIN tbAddStatus a
ON [m.AutoId] = [a.AddID]

We are the creators of our own reality!
Go to Top of Page
   

- Advertisement -