How do you run T-SQL commands on multiple servers from one place?

Posted on

Question :

I have some daily and weekly tasks where I run a script to get the required information. What is the way to running this code once and hitting all the servers without having to log into each one of them separately?

Answer :

There are a couple of ways to go about this, but natively it sounds like Central Management Servers is a pretty good fit for you.

If it is just “one” script and “one” functionality to pull the information, consider writing a quick PowerShell script that loops through all of your servers (the list of servers can be contained in a text file or a database table, etc.) and executes the script. This is quite simple and painless.

It all depends on how often your script(s) will change and what your comfort level is with each of the different approaches.

Leave a Reply

Your email address will not be published. Required fields are marked *