I am running into a mental block and trying to figure how I would run the following query against mulitple SQL servers. I thought about declaring a list within my query and simply running the query command against the list (that didn't work out for me), someone mentioned Powershell. I am relatively new still to Powershell. If anyone has any ideas to help that would be great.
Thanks.
DECLARE @tableHTML NVARCHAR(MAX) ;
SET @tableHTML =
N'<H2>DB Backups</H2>' +
N'<table border="0" style="font-family:Verdana;font-size:11px">' +
N'<tr><th>Database Name</th>' +
N'<th>Date</th>' +
N'<th>Backup Location</th>' +
N'<th>Server Name</th><th>Recovery Model</th><th>Backup Type</th>' +
N'<th>Time Taken</th>' +
CAST ( (
SELECT TOP 10
td = database_name, '',
td = backup_start_date, '',
td = physical_device_name, '',
td = server_name, '',
td = recovery_model, '',
td = '' ,
CASE s.[type]
WHEN 'D' THEN 'Full'
WHEN 'I' THEN 'Differential'
WHEN 'L' THEN 'Transaction Log'
END AS BackupType,
td = CAST(DATEDIFF(second, s.backup_start_date,s.backup_finish_date) AS VARCHAR(100)) + ' ' + 'Seconds'
FROM msdb.dbo.backupset s
INNER JOIN msdb.dbo.backupmediafamily m ON s.media_set_id = m.media_set_id
ORDER BY backup_start_date DESC, backup_finish_date
FOR XML PATH('tr'), TYPE
) AS NVARCHAR(MAX) ) +
N'</table>' ;
EXEC msdb.dbo.sp_send_dbmail
@recipients='someone@home.com',
@subject = 'DB Backups',
@body = @tableHTML ,
@body_format = 'HTML'