Wednesday, March 7, 2012

connecting to 2 databases inside one query

hi there,
I saw a similar thread before but i've tried it and no luck. I want run a query off a database (stawebdata.branchinfo) then a join into bluepages.phonelist

i've tired

JOIN bluepages.phonelist p

Incorrect syntax near the keyword 'JOIN'.

any ideas... is this possible?

complete code below:

select DISTINCT b.name, b.tel1, b.id, b.telprivate,b.sc, b.manager,b.branchEmail
from branchInfo b
inner
JOIN bluepages.phonelist p on b.name = p.subdepartment
where b.name like 'Sarah' or b.id LIKE '%@.keyword%' OR b.county LIKE '%@.keyword%' OR b.Area LIKE '%@.keyword%' OR b.Manager LIKE '%@.keyword%' OR b.AssistantManager LIKE '%@.keyword%' OR b.Postcode LIKE '%@.keyword%' OR b.PseudoCity LIKE '%@.keyword%' OR b.TicketingTA LIKE '%@.keyword%' OR b.SLC LIKE '%@.keyword%' OR b.ItineraryTA LIKE '%@.keyword%' OR b.TIDS LIKE '%@.keyword%' OR b.ABTA LIKE '%@.keyword%' and
p.department = 'UK Branch' and
b.isbranch <> 'False' or
(p.lastName = '@.keyword' or p.firstname = '@.keyword')
order by b.name asc
GOyou have to put

JOIN bluepages.dbo.phonelist

i thought "dbo" was a param!

derrr|||How about putting two dots:

JOIN bluepages..phonelist

Roshmi Choudhury

No comments:

Post a Comment