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
 General SQL Server Forums
 New to SQL Server Programming
 synchronize 2 table records

Author  Topic 

s2002
Starting Member

49 Posts

Posted - 2008-09-25 : 10:19:13
hi, I have there are 2 table with the same structure on my db.
table1 ID(PK) Count(integer)
table2 ID(PK) Count(integer)

there is not any relation between these 2 tables.
Now I want to update "Count" field records in table2 and set their value the same value of "count" field records
on table1 "where table2.ID=table1.ID"
I have think about something like this

UPDATE table2
SET table2.count = table1.count
where table2.ID=table1.ID

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-25 : 10:26:03
UPDATE t2
SET t2.count = t1.count
from table2 as t2 inner join table1 as t1
on t2.ID=t1.ID


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -