We have several environments (e.g., development, staging, test, training, production). When migrating a production database to a new version of SQL, we also migrate the related environments. Sometimes the developers want a refresh from production in development. Sometimes they want the old development database. A question came up about the source of a development database - was it from dev or production? If I'm lucky, the information I want is listed in the following query.
SELECT rh.[restore_date], rh.[destination_database_name], bs.server_name, bs.database_name FROM [msdb].[dbo].[restorehistory] rh LEFT JOIN [msdb].[dbo].[backupset] bs ON rh.backup_set_id = bs.backup_set_id WHERE bs.server_name <> @@SERVERNAME OR rh.destination_database_name <> bs.database_name
If I'm not lucky, the history is no longer present. This is often the case because we don't keep a lot of history. Is there any other metadata that will help me identify where a database came from? Should I insure that the most recent restore record for an existing db is not cleaned out, no matter how old it is? Thanks.
Randy in Marin