x

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, 2011 at 09:24 AM in Default

Chama gravatar image

Chama
92 12 16 17

(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][1]

[1]: http://msdn.microsoft.com/en-us/library/aa936675(v=sql.80).aspx
more ▼

answered Aug 23, 2011 at 09:41 AM

aRookieBIdev gravatar image

aRookieBIdev
2.3k 47 55 61

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, 2011 at 10:37 AM Chama
Now it is give this errotr invalid object NAME
Aug 24, 2011 at 06:20 AM Chama
Post your actual code.
Aug 24, 2011 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.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

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

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1945

asked: Aug 23, 2011 at 09:24 AM

Seen: 427 times

Last Updated: Aug 23, 2011 at 09:45 AM