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
 SQL Server Development (2000)
 Query problem

Author  Topic 

gilgamesh
Starting Member

14 Posts

Posted - 2002-05-15 : 06:04:27
Please help. I need to produce an alphabetical listing of two tables in separate databases (on the same SQL Server) that meet a certain criteria.

CUSTOMER TABLE
Select CustCode where CustAccNo = XXXXX
Select firstName, lastName where Sponsor = CustCode

and alphabetically sort that with

ADDRESSBK TABLE
Select firstName, lastName where Sponsor = XXXXX

Should this be done with Stored Procedure - oh please help its driving me mad!

Many thanks in advance!

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2002-05-15 : 06:24:18
look at the UNION construct...and you will also have to specify both tables with their full qualification....


select a,b from server1.database1.owner1.table1 where a = xxx'
union
select a,b from server2.database2.owner2.table2 where b = z
order by 1,2


the databasex.ownerx part may need to be reversed ie....ownerx
.databasex


do a FORUM SEARCH on tables + servers...should give some useful links to explain this.

Go to Top of Page

gilgamesh
Starting Member

14 Posts

Posted - 2002-05-15 : 06:40:50
Thanks a lot Andrew

Go to Top of Page
   

- Advertisement -