Another question I got at the denver launch was how can someone check to see if a database (in SQL 2005) was backed-up or not. There is a couple of ways you can get this information
- Use the SQL Management Studio. Open the studio, right click on the database in question, choose restore, restore database... On the general tab you will see the backup sets associated to this database.
- If you have a backup file and want to get more information, you can use commands RESTORE FILELISTONLY, RESTORE HEADERONLU, RESTORE LABELONLY. Please refer to books online to get detailed information about these commands.
- Go and query the MSDB tables directly.MSDB contains all the information you will need about the what backups have ran. for instance, to query all the backup sets for a database called “FOO“ you could execute “Select * from backupset where database_name='foo'“. Other tables you might be interested in are: Backupfile, Backupfilegroup, Backupmediafamily, Backupmediaset, Backupset. Complete descriptions of these tables can be found in books online.