I had some spare time lately and I had the chance to re-write one of my old favourite tools: QueryLauncher.
Problem
Sometimes you find yourself alone and you need to run a query or a set of queries against a data warehouse that has hundreds or thousands of SQL Server instances. How to do that?
Solution
Poor DBA needs help, presto!
You need to download QueryLauncher which consists in:
- Queries: a folder in which you put your queries
- Results: a folder in which you will have the results
- QueryLauncher.ps1: the actual script that will make the job for you
The new version only takes 20 lines of code as it uses DBATools and ImportExcel libraries. So no need to install Office suite on your jump server.
just run:
1 2 |
Install-Module -Name dbatools Install-Module -Name ImportExcel |
Then modify the first line of the script and insert a list of target server names:
1 |
$SqlInstances = 'ServerName1','ServerName2','ServerName3' |
…and voilà, you are good to go, watch the video:
Conclusions
I really like this tool as it allows me to run not only one query but a set of queries against a whole data warehouse.
Thanks to DBATools now the connections are handles by a solid library and thanks to ImportExcel library you don’t have to hardcode the Excel import with COM objects.
And now stop blogging and go to do real work, poor DBA!