I have 50 servers. I manage them from a central management server on SQL Server 2014 Enterprise Edition. I don't use repository.
I could open a query and get result for each one at the same time. But I want to do it in an automated way, like a job, to collect data from each server and store/handle it locally.
Is this possible and if so, how?
Best Answer
What you can do is the following:
Once you have created a linked server, you can query data from it as follows:
Depending on what you need in your business case, you can create a view for each such table you want to query:
You can query them as you would a regular table:
Or you could create a view that combines all the data from all those linked servers:
You can then query all data from all linked servers as follows:
You can use these views from a SQL Server job if need be.
If you have a table in your CMS containing all the information required to create the linked servers, then you can keep track of which linked servers/views you already created and in your job create linked servers and views for those that haven't been created yet (or for a select-it-all view, recreate it to also select for newly added linked-servers).
AFAICT there is no automated way to execute a query against of a group of servers that comes out of the box in SQL Server. Perhaps there exist tools that automate this for your? I haven't worked with any but they might exist.
But suppose you created linked servers for all 50 servers in your CMS, and you've created a view for each of the tables in those servers you want to query. Is the script that selects one after the other, as in:
...not good enough?