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
 Inner Join across two Data Sources

Author  Topic 

dave0109
Starting Member

3 Posts

Posted - 2011-09-21 : 12:15:08
I need to join two databases on separate servers based on phone number fields.

I have a call management system and a CRM system that aren't linked.

My aim is to link the phone number in the two databases so that I can see company names, relationship type etc from the crm system.

Two problems are:

Inner join and formating the CRM Phone Number field i.e. removing white spaces.

Any ideas?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-09-21 : 12:27:21
you need to add linked server to one of system in another and then use four part naming to access the table
for ex:



USE [CRMDB]

SELECT required columns...
FROM table t
JOIN [CMS]..dbo.table t1
ON t1.phonenumber = t.phonenumber


I've given indicative db names so please replace them with actual names

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-21 : 12:27:45
If they are on separate servers, then you can add a linked server to refer to the remote server.

To remove white space, you can use RTRIM/LTRIM/REPLACE.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

dave0109
Starting Member

3 Posts

Posted - 2011-09-21 : 12:31:28
Great, thanks for this I'll give it a go.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-09-21 : 12:34:06
Glad to help.

I moved your topic out of the article forum since this isn't an article.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -