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 get the value from the two diff database

Author  Topic 

shm
Yak Posting Veteran

86 Posts

Posted - 2008-10-23 : 08:01:25
hi all,
am taking two diff database am joining these by one of the col's from this am doing some calculation..wt my doubt is -- 1st db col has value but 2nd db col there is no value..for this am not getting any result..atleast it shld come the 1st db value and for the 2nd db col null or zero shld come...wt i shld do for this?

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-10-23 : 08:07:44
left join should be your friend.

Webfred

No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-23 : 08:13:18
if databases are in same server you could simply use like this

select * from db1.dbo.table1 t1
left join db2.dbo.table2 t2
on t2.col=t1.col
Go to Top of Page
   

- Advertisement -