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)
 How to fetch data from other data base

Author  Topic 

Avinash
Starting Member

5 Posts

Posted - 2007-12-04 : 07:00:31
Hi Experts,

I am using sql server 2005. I have two database in same server i.e. DB1 and DB2. DB1 contains table1 and DB2 contains table2.

i have to run a sql query in DB2 to fetch data from table1 and to update in table2.

Please suggest.

Thanks in advance.

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-04 : 07:09:14
[code]Update t2
Set Col = t1.col
From db2.dbo.table2 t2 join db1.dbo.table1 t1
on t1.key = t2.key[/code]

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

Avinash
Starting Member

5 Posts

Posted - 2007-12-04 : 08:31:26
Thanks Harsh..It's working fine.
Go to Top of Page
   

- Advertisement -