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 2000 Forums
 Transact-SQL (2000)
 joining tables and views of 2 databases

Author  Topic 

ovince
Starting Member

32 Posts

Posted - 2006-11-09 : 05:11:45

hi All,

This is a first time to meet this kind of problem and I would like to consult more experienced forumers

I have 2 databases (db1 and db2). I would like to extract some data from db1 View named 'viw' AND db2 Table named 'tab' using some filtering. So I wrote this:



select s.data1, m.data2
from db1.viw s, db2.tab m
where
s.data1=m.data1
s.data2=m.data2
s.data3=m.data3



It does not work. What I do wrong?

Thank you
Oliver

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-09 : 05:14:01
SELECT s.data1, m.data2
FROM db1..viw s
inner join db2..tab m on s.data1 = m.data1 and s.data2 = m.data2 and s.data3 = m.data3


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-09 : 05:18:00
It would have been nice if you also provided the error messages "Invalid object name 'db1.viw'" and "Invalid object name 'db2.tab'"


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

ovince
Starting Member

32 Posts

Posted - 2006-11-09 : 05:26:00
Peter,

this was very fast reply really :) as last time as I remember. you are very kind


thanks
oliver


Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-11-09 : 05:41:19
Ketö sör!


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

ovince
Starting Member

32 Posts

Posted - 2006-11-09 : 06:14:15
:) Its ok by me
Go to Top of Page
   

- Advertisement -