![]() We can find the SQL server database last restore time using the system table in msdb.Īs part of our Server Management Services, we assist our customers with several SQL queries. Today, let’s focus on Database Backup and the last restore time.ĭatabase Backup and restores are common tasks for any database administrator. Similarly, we can also get information about the last restore time of the database. There is a system table named restorehistory in msdb system database that captures this information. We run the T-SQL code below to get this info: use msdb go select Destination_database_name AS ,user_name AS ,restore_date As from restorehistory where Destination_database_name like (‘qa%’) We need to gather information from this table to get the data. Once we run the above command, we will get output. Here, we can see the database name, a user that has restored the database, and the last restore date and time. Restorehistory system table is very informative in case we need information for audit or database forensics purposes. This table contains the row for each database restoration performed. If you dont see the one you want, click More apps or Look for another app on this PC to look for other applications. We get the following database restoration history. On Windows operating systems, right-click the DBS file, select Open with, and click Choose another app from the menu that appears.restore_date: It shows the database restoration date.destination_database_name: Here, we can get the destination database name using this column.user_name: Gives the user name that performed the restoration for that particular database.backup_set_id: We can join this column with backupset table to get information about the backup file.restore_type: We can use this column to know the kind of database restoration performed on a particular database.replace: once we execute a database restore command, we set this option to replace the existing destination database.recovery: In the database restore query, we also specify the Recovery and Norecovery option.Restart: It shows whether the restore operation specified the RESTART option or not.restorefile: We get the row for the restore file.We can join this table with restorehistory table on the restore_history_id column as well. ![]() Destination_phys_name: It gives the name of the physical file with the complete path.We will get the detail of each physical file.restorefilegroup: We can do filegroup restore as well in SQL Server.Ī FILEGROUP backup and restore allows restoring the objects related to a specific filegroup only.Generally, each database has a Primary filegroup that contains the primary data file MDF.: We can join this column with other MSDB tables to get more information.Filegroup_name: It is the name of the FILEGROUP on which restoration was performed.
0 Comments
Leave a Reply. |