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
 Transact-SQL (2005)
 Update using tables from different databases

Author  Topic 

Razzle00
Starting Member

35 Posts

Posted - 2007-07-11 : 09:33:44
Hi,

I need to update a field in a table from a field in another table from a different database. What would the correct syntax be for this. I am trying it like this, but it does not work.

UPDATE quiz.dbo.staffm
SET q.facility = b.facility
FROM quiz.dbo.staffm AS q
INNER JOIN brdpayroll.dbo.staffm AS b
ON q.access = b.access


The error I get is this....

Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "q.facility" could not be bound.

Thanks,

Razzle

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-07-11 : 09:36:00
[code]UPDATE q
SET q.facility = b.facility
FROM quiz.dbo.staffm AS q
INNER JOIN brdpayroll.dbo.staffm AS b
ON q.access = b.access[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Razzle00
Starting Member

35 Posts

Posted - 2007-07-11 : 10:03:50
Thanks harsh_athalye!

That worked.
Go to Top of Page
   

- Advertisement -