Sometimes you stuck in situation where you need to run same set of queries on different servers.
Sometimes it is a real pan when you need to fetch records from all the server then basic approach you follow run query on different instance once by one.
I would like to share here one important facility provided in SQL Server management studio which is
With the help of Register Servers option you can run same query for the entire servers which you have registered.
You can access the “Register Servers” option from View ==> Register servers OR by pressing “CTRL + ALT + G” keys.
As shown below fig
Once you press the menu or follow above keys then you will get Register Servers option screen as shown in below fig.
You can right click on Local Server Groups and can create your own group also
Once the group is created you can move your Registered servers on which you want to run query in that group with right click move option on Group Folder
As you did this job your database server will come in the particular group folder as shown in below fig
Now right click on your group folder and go for option New Query
As you go for option new query a new query window will be open there
Now write proper query which you want to run on same database at different servers and execute it with F5 option
You will find when you will execute the result will show in query result window which is just below the query with starting column server name.
Now you have option whether you want merge result or Individual result.
To check that option you need to go Tool –> Option then Query Result option as shown below fig
This trick will help you in many ways to get the results from different server as well as to find results from different servers.
Thanks & Regards,
Keep Learning, Keep Sharing