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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SELECT from 2 servers ?

Author  Topic 

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2012-07-10 : 10:06:48
Hi All

I have 2 SQL Servers registered in my SSMS.

When writing ad-hoc queries in the query window is it possible to select from tables that reside on different servers (both SQL Server 2008)?

Can i do something like...

SELECT
MyFields
FROM
serverName.databaseName.owner.tableName
INNER JOIN
serverName.databaseName.owner.tableName

Any pointers welcome

Thanks

====
Paul

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-10 : 10:10:05
read about linked server please.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2012-07-10 : 10:13:39
Thanks Fred - i'm actually doing that now :)

====
Paul
Go to Top of Page

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2012-07-10 : 10:49:26
consider replication as well. Always nice to have a local copy.

Be One with the Optimizer
TG
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-07-10 : 12:35:58
if its ad hoc one time need you can even use OPENROWSET

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

Go to Top of Page

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2012-07-11 : 04:53:09
quote:
Originally posted by visakh16

if its ad hoc one time need you can even use OPENROWSET

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





Thanks for the reply, it is a one time need so that may be perfect i'll take a look - thanks

====
Paul
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-07-11 : 04:57:46
it is a one time need

famous last words


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

KnooKie
Aged Yak Warrior

623 Posts

Posted - 2012-07-11 : 05:04:38
quote:
Originally posted by webfred

it is a one time need

famous last words


No, you're never too old to Yak'n'Roll if you're too young to die.



It had better be or our IT dept is going to get a kick in the butt :)

====
Paul
Go to Top of Page
   

- Advertisement -