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
 General SQL Server Forums
 New to SQL Server Programming
 Help with a query

Author  Topic 

spowell
Starting Member

23 Posts

Posted - 2008-09-28 : 16:49:41
Hi

I am quite new to sql and really need some help with this.

I am trying to create a report that shows the name, address, phone number & product sold to 16,000 customers. The problem I have is that this information is in 2 seperate databases. The first database is called dbo.maindata_withphone2709 and has all the contact information in (for 100,000 records) and the second database is called dbo.tblcompletion whihch has the product information in. The only link between the tables is a unique id number.

The columns I need to display from each database are

dbo.maindata_withphone2709

ID
Prefix
Firstname
Surname
Address_1
Address_2
Address_3
Postcode
Telephone

dbo.tblcompletion
ID
Agreed_product
Commission

Any help will be greatly appreciated

Steve

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-09-28 : 16:55:01
Two different databases, or two different tables? From the names you gave, those are two separate tables and can be simply joined together with an INNER JOIN

SELECT <column list>
FROM dbo.maindata_withphone2709 maindata INNER JOIN dbo.tblcompletion compl on maindata.id = compl.id

--
Gail Shaw
SQL Server MVP
Go to Top of Page

spowell
Starting Member

23 Posts

Posted - 2008-09-28 : 17:45:46
Thanks a lot. That worked perfectly
Go to Top of Page
   

- Advertisement -