You can try this: In the View menu, select Registered Servers. Add the servers you are querying in Local Server Groups, or create a new group and the servers to that group. Then right-click the group and select New Query. This permits you to run queries on all servers in the group at once.
Combine SQLCMD Outputs In One Window
I am using SQLCMD Mode in SSMS v18.9.1. When I run a query across multiple unlinked servers, the results from each server display in their own separate window. I then have to copy each set of results out of my virtual machine into Excel on my actual pc, which is time consuming. I want to know if there is a way to combine the results from each output window in SSMS into one final output so that I can copy all records out into Excel at one time. Thank you!
SQL Server | Other
4 answers
Sort by: Most helpful
-
Erland Sommarskog 128.7K Reputation points MVP Volunteer Moderator2022-02-10T22:21:49.063+00:00 -
CathyJi-MSFT 22,401 Reputation points Microsoft External Staff2022-02-11T02:48:03.017+00:00 Hi @possibilities ,
If the query run on the multiple SQL server instance are same, you can try the method that Erland mentioned. Below is a test in my environment.
If the query run on the multiple SQL server instance are different, you can open a Query windows type “:connect” syntax to multiple instance as below screenshot.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
-
possibilities 41 Reputation points
2022-02-11T20:25:01.27+00:00 Thank you both for your help. I am still not getting the code to work but don't want to waste your time any further.
-
possibilities 41 Reputation points
2022-10-21T18:28:15.197+00:00 I wanted to let all of you know that I did get Linked Server Groups to work. Thanks again for all of your help.