Last SQL Server Database Backup

programming-transactsql

As a data professional you will sometimes be asked to verify one of the most basic functions of a Database Administrator: Database Backups. When I have to audit a SQL Server instance,  one of my first checks is to make sure that backups are being performed.  A quick check is to see when the last full backup was made is fairly easy to perform.

SELECT  a.Name AS [DB_Name],

        COALESCE(CONVERT(VARCHAR(12), 
                 MAX(b.backup_finish_date),
                 101), '-') AS LastBackup

FROM    sys.sysdatabases a
 LEFT OUTER JOIN msdb.dbo.backupset b 
        ON b.database_name = a.name

GROUP BY a.Name

You can get additional information about database backups from Microsoft.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s