﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / SQL Server 2008 / T-SQL (SS2K8)  / Connecting to multiple sql servers / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Sat, 25 May 2013 19:14:04 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>[quote][b]John Mitchell-245523 (1/7/2013)[/b][hr]If this is an ad hoc query you wish to run against multiple servers, you might consider setting up a Central Management Server.John[/quote]+1 to that</description><pubDate>Tue, 08 Jan 2013 01:31:04 GMT</pubDate><dc:creator>anthony.green</dc:creator></item><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>[quote][b]alex 64682 (1/7/2013)[/b][hr]Many thanks for all the responses. I haven't encountered Openrowset before but it looks like the best option. Not entirely sure where to place the remote IP Address, port number etc for the connection string though, don't suppose anyone has examples of this type of thing?[/quote]I believe that the IP address can be part of the HOSTNAME shown by e4d4 in his example below.[quote][b]e4d4 (1/4/2013)[/b][hr]You could use linkedservers, openrowset [url]http://msdn.microsoft.com/en-us/library/ms190312.aspx[/url] or openquery [url]http://msdn.microsoft.com/en-us/library/ms188427.aspx[/url]eg. openrowset [code="sql"]SELECT * FROM OPENROWSET('SQLOLEDB', 'Server=HOSTNAME;UID=DB_USER;PWD=StronPassword;','select * table');[/code][/quote]Beware though, that the arguments passed to OPENROWSET must be string literals; no local variables are allowed.</description><pubDate>Tue, 08 Jan 2013 01:26:08 GMT</pubDate><dc:creator>dwain.c</dc:creator></item><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>If this is an ad hoc query you wish to run against multiple servers, you might consider setting up a Central Management Server.John</description><pubDate>Mon, 07 Jan 2013 04:36:39 GMT</pubDate><dc:creator>John Mitchell-245523</dc:creator></item><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>Many thanks for all the responses. I haven't encountered Openrowset before but it looks like the best option. Not entirely sure where to place the remote IP Address, port number etc for the connection string though, don't suppose anyone has examples of this type of thing?</description><pubDate>Mon, 07 Jan 2013 04:23:46 GMT</pubDate><dc:creator>alex 64682</dc:creator></item><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>alex, I think e4d4's suggestion is probably your best (and maybe only) option.  Once you set up the linked servers, you can query against them like this...[code]SELECT a.&amp;lt;column_list&amp;gt;, b.&amp;lt;column_list&amp;gt;  FROM Linkedserver1.catalog.schema.table a INNER JOIN	   Linkedserver2.catalog.schema.table b	ON some join criteria[/code]I'm not sure if the catalog is required for linked servers to other SQL Servers, but I have them set up to some DB2 and Oracle databases without the catalog, and I am able to bring them into the same query just fine.  One caveat, though, the queries take an extremely long time to run.  Now, I don't have exposure to the remote catalogs, so I'm not sure if there might be some index info in there that would make them run faster if I could read them.  In general, using OPENQUERY(Linkedserver,'your SQL') is much faster than using the 4 part naming convention if you are only hitting one remote.</description><pubDate>Fri, 04 Jan 2013 13:20:43 GMT</pubDate><dc:creator>Greg Snidow</dc:creator></item><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>I just finished looking into this! :) You can use "SQLCMD Mode" in SSMS.  To enable it go to the Query menu and select "SQLCMD Mode":connect &amp;lt;ServerName&amp;gt;\&amp;lt;InstanceName&amp;gt;use [Database]goSELECT * FROM [dbo].[TABLE]:connect &amp;lt;ServerName2&amp;gt;use [Database2]goSELECT * FROM  [dbo].[TABLE2]</description><pubDate>Fri, 04 Jan 2013 12:06:27 GMT</pubDate><dc:creator>Khaavren</dc:creator></item><item><title>RE: Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>You could use linkedservers, openrowset [url]http://msdn.microsoft.com/en-us/library/ms190312.aspx[/url] or openquery [url]http://msdn.microsoft.com/en-us/library/ms188427.aspx[/url]eg. openrowset [code="sql"]SELECT * FROM OPENROWSET('SQLOLEDB', 'Server=HOSTNAME;UID=DB_USER;PWD=StronPassword;','select * table');[/code]</description><pubDate>Fri, 04 Jan 2013 11:55:44 GMT</pubDate><dc:creator>e4d4</dc:creator></item><item><title>Connecting to multiple sql servers</title><link>http://www.sqlservercentral.com/Forums/Topic1402974-392-1.aspx</link><description>Hi,I'd like to connect to multiple databases on different servers all from the same query. So, is it possible to specify a connection string when using the "USE" keyword?e.g. USE Data Source=11.11.111.11,111;Initial Catalog=Blah;User ID=BlahSelect * from Blah;USE Data Source=22.22.22.22,222;Initial Catalog=Blah;User ID=BlahSelect * from Blah;</description><pubDate>Fri, 04 Jan 2013 10:02:48 GMT</pubDate><dc:creator>alex 64682</dc:creator></item></channel></rss>