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 data accross 2 databases

Author  Topic 

Antinsh
Starting Member

16 Posts

Posted - 2008-03-14 : 05:03:37
I have to DBs. One is the original and the other is for testing. They both have similar data structure. Wanted to know if there is a way to update tables contents in one db with data that is in the other one.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-14 : 05:11:34
Do you want the table in second database to contain exactly same data as first one?

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

Antinsh
Starting Member

16 Posts

Posted - 2008-03-14 : 05:30:34
No want to create an update that would update one particular field in orginial database table and not for all rows
Basicly:

UPDATE myTable
SET imageField (field in Original)=imageFiled(field in db where are the right data)
WHERE ID=1234
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-14 : 05:38:17
[code]UPDATE T1
SET T1.FIELD1 = T2.FIELD1
FROM DB1.DBO.TABLE1 T1 JOIN DB2.DBO.TABLE1 T2
ON T1.ID = T2.ID
WHERE T2.ID = 1234[/code]

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

Antinsh
Starting Member

16 Posts

Posted - 2008-03-14 : 08:23:56
Thanks
Go to Top of Page
   

- Advertisement -