1. Enable collection of historical data for transactions
a. In Spotlight application, from Configure toolbar select Scheduling option.
b. Choose the monitored Windows connection name from top dropdown list.
c. From list of collections, scroll to ‘Services’ and edit this collection.
d. Uncheck Factory Settings option and check ‘Store reporting data’ option and if needed change the collection interval time. Click OK.
e. Apply the above setting to all or desired Windows servers by using the 'Apply Configuration To' option
f. Hit Ok and wait until data is collected before running the script.
2. Open SSMS and connect to the instance where Spotlight Statistics Repository database resides. Run attached script against this database.