I am devising a way to help you out in looping, as I know the tidious job in doing recursive work for a volume as big as 100 servers.....
As of now, the following process will let you save your outputs to a centrally located excel file. This will do away with the copy and paste stuff each time you run the script for a server.
First of all share a folder and create a blank excel workbook with a worksheet named Result. Name the columns SERVER, PRODUCTVERSION, PRODUCTLEVEL, EDITION in the worksheet.
as before run the following script for each of the servers you want to drill in...changing just the servername SON1286
:setvar defaultserver SON1286
IF NOT EXISTS (SELECT srv.name
FROM sys.servers srv
WHERE srv.server_id != 0
AND srv.name = N'ExcelSource')
EXEC sp_addlinkedserver 'ExcelSource',
DECLARE @TSQLSTMT VARCHAR(4000),
SET @TSQLSTMT = 'Insert ExcelSource...[Result$]
Note: You must not have any linked server already on your servers named ExcelSource. You can choose a unique name if required.
DBA – MS SQL Server
Ericsson India Global Services Limited
Quality is not an act, it is a habit.