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)
 Query help needed for the sql challenged...

Author  Topic 

acribb
Starting Member

19 Posts

Posted - 2006-12-04 : 10:47:33
Here is another easy one for you.

I have this query which selects 100 loan officers meeting various conditions within the same database.

SELECT TOP 100 lu.username, lu.lo_id, lo.lo_name, lo.lo_email
FROM lo_users lu
INNER JOIN loanofficer lo ON lu.lo_id = lo.id
WHERE (lu.company_id = 1) AND (lu.lo_id IS NOT NULL) AND (lu.lo_id <> 0)
ORDER BY lu.username

However, I now need to add in the condition that the enrollmentStatus needs to be 'active' on another table called LoanOfficers within another database called STMContinuity. I would like the enrollmentStatus field added to query result.

Can you help with this?

Thanks again.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 10:49:54
INNER JOIN or LEFT JOIN that table too...


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

acribb
Starting Member

19 Posts

Posted - 2006-12-04 : 11:01:11
How do you do inner joins across 2 different databases?
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 11:04:21
Add the other database as a LINKED SERVER.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

acribb
Starting Member

19 Posts

Posted - 2006-12-04 : 12:45:46
Ok, got it working. Thanks for the help.
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2006-12-04 : 13:13:41
quote:
Originally posted by Peso

Add the other database as a LINKED SERVER.


Peter Larsson
Helsingborg, Sweden



Excuse me?

Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-04 : 13:36:03
Well, I figured out that if he doesn't know about Db.Owner.Table.Column syntax, the "other database" must be on a different server.


Peter Larsson
Helsingborg, Sweden
Go to Top of Page
   

- Advertisement -