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)
 sql updates using 2 different databases

Author  Topic 

sparky753
Starting Member

7 Posts

Posted - 2008-03-04 : 14:21:34
I have 2 databases with the same tables, etc. I'm trying to copy one column from the same table from db1 to db2. Here is my sql:

update db1.dbo.table1 set db1.dbo.table1.memtype = db2.dbo.table1.memtype where db1.dbo.table1.memid = db2.dbo.table1.memid


When I parse it, it completes successfully but when I execute it, I get this error message:
The multi-part identifier "db2.dbo.table1.memid" could not be bound.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-04 : 14:23:51
update x1
set x1.memtype = x2.memtype
from db1.dbo.table1 as x1
inner join db2.dbo.table1 as x2 on x2.memid = x1.memid


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

sparky753
Starting Member

7 Posts

Posted - 2008-03-04 : 14:37:22
Thanks a bunch!!
Go to Top of Page
   

- Advertisement -