Backupset server name on dev server shows Prod server name

by John Waclawski   Last Updated June 20, 2018 01:06 AM

I'm using the following code to determine the last time a database was backed up:

SELECT
@@ServerName as HostServerName
   ,bus.server_name AS BUSservername
   ,sdb.Name AS DatabaseName
   ,COALESCE(CONVERT(VARCHAR(12), MAX(bus.backup_finish_date), 101), '-') AS LastBackUpTime
FROM sys.sysdatabases sdb
LEFT OUTER JOIN msdb.dbo.backupset bus
ON bus.database_name = sdb.name
WHERE 
   bus.backup_start_date >= DATEADD(DAY, DATEDIFF(DAY, 1, GETDATE()), 0) -- Previous day at midnight.
   AND bus.backup_start_date < DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()), 0) -- Today at midnight.
GROUP BY 
   sdb.Name
   ,bus.server_name

And it appears to show the data I'm looking for, but if I run this code on a development server, for example, it shows its corresponding production server as the bus.server_name value. I'm trying to understand why it's showing a production server' name and not itself. I may not be understanding how the backupset table is getting its value.
I know I can use @@ServerName for that value but I'm not sure if that is correct way to get that value. Below is a screenshot of my results with the server names obviously blacked out: Last Backupset results



Related Questions



MongoDB Backup & purge

Updated May 18, 2015 23:02 PM