user3734454
user3734454

Reputation: 59

Joining another database into SQL query

I was able to join another database into my query in access as shown

LEFT JOIN  [X:\Zodds and Ends\Emer\T2Data.MDB].tblContacts 
ON EeDetails.BankCode = tblContacts.FirstName)

I am changing this query over to SQL Server but I cant find a way of linking the database I have also tried this but it doesn't work.

LEFT JOIN T2Ddata..tblContacts ON EeDetails.BankCode = tblContacts.FirstName)

Upvotes: 1

Views: 56

Answers (1)

Donal
Donal

Reputation: 32713

The syntax is LEFT JOIN databasename.schemaname.tablename

The default schema is dbo. So it is usually: databasename.dbo.tablename

Also, it is a good idea to use an alias

LEFT JOIN T2Ddata.dbo.tblContacts c ON c.id = e.ContactId)

I doubt if you would be joining on FirstName?

Upvotes: 2

Related Questions