sql server backup functions code example

Example: t-sql backup names

SELECT CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server,
       b.database_name,
       b.backup_start_date,
       b.backup_finish_date,
       b.expiration_date,
       CASE b.type
           WHEN 'D' THEN 'Database'
           WHEN 'L' THEN 'Log'
       END AS backup_type,
       b.backup_size,
       a.logical_device_name,
       a.physical_device_name,
       b.name,
       b.description
FROM msdb.dbo.backupmediafamily a
INNER JOIN msdb.dbo.backupset b
    ON a.media_set_id = b.media_set_id
ORDER BY b.database_name,
         b.backup_finish_date DESC;

Tags:

Sql Example