x
login about faq Site discussion (meta-askssc)

How to created a query with two different sever and database

I know how to link two different database , i totally forget how to link to different server in a query... this only join two different database what about the two different sever


SELECT [Name ofdatabase1].[table name].[field name], 
     [Name ofdatabase2]table name].[field name]
FROM [Name ofdatabase1].[table name] 
INNER JOIN [Name ofdatabase2].table name]ON 

[Name ofdatabase 1.table name].[field name] = [Name ofdatabase2].[table name].[field name]
more ▼

asked Aug 23 '11 at 09:24 AM in Default

Chama gravatar image

Chama
91 5 9 13

(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

if you add the server to your linked server list , then you can write a query like

 SELECT [ServerName].[Name ofdatabase1].[table name].[field name],  [ServerName].[Name ofdatabase2]table name].[field name]

FROM [ServerName].[Name ofdatabase1].[table name] INNER JOIN [ServerName].[Name ofdatabase2].table name]ON

[ServerName].[Name ofdatabase 1.table name].[field name] = [ServerName].[Name ofdatabase2].[table name].[field name]

chk the below link to know more about linked servers

Adding a Linked Server

more ▼

answered Aug 23 '11 at 09:41 AM

aRookieBIdev gravatar image

aRookieBIdev
2k 24 40 46

thank you...i did but i have a error message an expression of non-boolean type specified in a context where a condtion is expectedd near 'INNER'

Aug 23 '11 at 10:37 AM Chama

Now it is give this errotr invalid object NAME

Aug 24 '11 at 06:20 AM Chama

Post your actual code.

Aug 24 '11 at 06:23 AM Magnus Ahlkvist
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1835

asked: Aug 23 '11 at 09:24 AM

Seen: 236 times

Last Updated: Aug 23 '11 at 09:45 AM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.