p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   SQL Server 2000 (http://p2p.wrox.com/forumdisplay.php?f=20)
-   -   Query Between Servers (http://p2p.wrox.com/showthread.php?t=39177)

nikotromus February 28th, 2006 08:40 PM

Query Between Servers
 
Hey Guys,

In SQL Server, I am trying to figure out how to write a query between two different tables on two different databases, with the databases located on two different servers. For instance, I want to join table a in database x located on server 1 with table b located in database y on server 2. Any idea how that query would look in Enterprise Manager, and/or how would that query work in a vb.net application.

Thanks,


nikotromus

SQLScott February 28th, 2006 10:10 PM

In SQL Server 2005 you can select across databases (not 2000), not sure about across servers. I will try across servers tomorrow at work where I have two SQL 2005 boxes.

Scott


Gert March 1st, 2006 05:47 AM

There is no problem selecting across databases in 2000, you just prefix the tablename with database-name and owner-name like this:

Select * from [databasename].[Ownername].[tablename]

If you need to select from another physical server, you could set up a linked server and then do the select like this:

Select * from [LinkedServerName].[databasename].[Ownername].[tablename]


Gert



All times are GMT -4. The time now is 05:31 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.