Quantcast
Channel: SQLServerCentral » SQL Server 2014 » Development - SQL Server 2014 » Latest topics
Viewing all articles
Browse latest Browse all 3145

Finding NULL in CASE Statement

$
0
0
The below code returns a NULL for all the Differential backups. I am trying to return the word Differential when there is a NULL because I can tell from when the NULLs occur that those are my differential backups. How can I get the result I want?SELECT CONVERT(CHAR(100), SERVERPROPERTY('Servername')) AS Server, msdb.dbo.backupset.database_name, msdb.dbo.backupset.backup_start_date, msdb.dbo.backupset.backup_finish_date, CASE WHEN msdb..backupset.type = 'D' THEN 'Database' WHEN msdb..backupset.type = 'L' THEN 'Log' WHEN msdb..backupset.type IS NULL THEN 'Differential' END AS backup_type, (msdb.dbo.backupset.compressed_backup_size/1000/1000) AS CompressedBackupSize_MB, (msdb.dbo.backupset.compressed_backup_size/1000/1000/1000) AS CompressedBackupSize_GBFROM msdb.dbo.backupmediafamily INNER JOIN msdb.dbo.backupset ON msdb.dbo.backupmediafamily.media_set_id = msdb.dbo.backupset.media_set_id WHERE (CONVERT(datetime, msdb.dbo.backupset.backup_start_date, 102) >= GETDATE() - 7) ORDER BY msdb.dbo.backupset.database_name, msdb.dbo.backupset.backup_finish_date

Viewing all articles
Browse latest Browse all 3145

Trending Articles