tags:

views:

39

answers:

1

How can I update a table (MyTable) from a aprticular database (DB1) by equating the said MyTable from a different database (DB2) but it has the same tablename with the one I need to update. I tried putting alias to my program but it doesn't work. Need Help

A: 

A SQL Server answer is

UPDATE    t2
SET       t2.Col1 = t1.Col1, t2.Col2 = t1.Col2
FROM         DB1.dbo.MyTable AS t1 INNER JOIN
                      DB2.dbo.MyTable AS t2 ON t1.PK = t2.PK

(Obviously alter the joining condition and update column list as required)

Martin Smith