SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

AD HOC Queries with Excel Output (Multiple Instances)

By Gonzalo Moles,

This is a PowerShell Script

1. Create a plain text with all your SQL Instances (one by line)

2. Modify the script to change the path\file that contains all you instances names

3. Insert the SQL code in this script with the query you want to check
as this:

4. Run the query.

5. You will have an excel file with your query result per instance as this:

This is very useful for reporting because you can use the query you need (ad hoc).

In the code you can change:

1. The location and name of files

2. The SQL Query Statement


Total article views: 1132 | Views in the last 30 days: 1
Related Articles

Script to document SQL Instance Details

SQL Script to document instance details


SQL Server Long Query Script

SQL Server Long Query Find Script


HOw to script out all the jobs from one instance

HOw to script out all the jobs from one instance


SQL Instance checkings.

Connecting to multiple SQL instance(s) and running a script.


Dynamic Script to Generate Backup Script

Use this script to generate BACKUP DATABASE scripts for selective or all databases during Instance o...