Connecting to multiple servers at once from an existing query window?

  • I know you can right click on the "Local Server Groups" in the Registered Servers panel and select "New Query" to run queries against all you registered servers. But is there any way to take an existing single server query and connect it to a second (or more) server?

  • Not with SSMS. You can cange the connection of a query window, but the new connection will always be to a single server.

    If you want to do that with multi-server queries, copy/paste the query from the single server query window to the multi-server query window or open the file once connected to the multi-server query window.

    -- Gianluca Sartori

  • spaghettidba (3/8/2016)


    Not with SSMS. You can cange the connection of a query window, but the new connection will always be to a single server.

    If you want to do that with multi-server queries, copy/paste the query from the single server query window to the multi-server query window or open the file once connected to the multi-server query window.

    Thanks for the reply. I thought it wasn't possible and what you suggest is what I do now. Just thought there might be some trick of the trade I was missing 🙂

  • Siberian Khatru (3/8/2016)


    spaghettidba (3/8/2016)


    Not with SSMS. You can cange the connection of a query window, but the new connection will always be to a single server.

    If you want to do that with multi-server queries, copy/paste the query from the single server query window to the multi-server query window or open the file once connected to the multi-server query window.

    Thanks for the reply. I thought it wasn't possible and what you suggest is what I do now. Just thought there might be some trick of the trade I was missing 🙂

    The only trick of the trade I know (and use when needed) is to open a new query window, then copy/paste the query from the existing window. Ctrl-A / Ctrl-C / Tab / Ctrl-V. Four keystrokes, that's the fastest method I know of.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Allow me to say, actually, sort of. Depending on how hard you want to work.

    You can use Linked Servers to run the query against multiple server connections, but you'll have multiple copies of the query in the same window each using a different linked server, or have to alter the query each time you run it to use the next linked server.

    So, yeah, it is possible. Sort of.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

  • Use the registered servers, and create a sub-group with only the couple of servers you want to run your query against. Right click the sub-group > new query.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply