Rahul
1 min readAug 2, 2020

--

SQL Managed Instance database properties window getting “Subquery returned more than 1 value” error message

While opening the database properties of one SQL MI, getting below following error message

Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression. \(.Net SqlClient Data Provider\)

This seems to be a known issue and could happens because there are multiple database_guids for the same database_name in msdb..backupset.

To resolve this, we need to clear the backup history in the backend by deleting the backup history details of that DB.

Before deleting the backup history, we can take a backup of the history in a table

  • Database Backups for all databases For Previous Week

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,

msdb.dbo.backupset.expiration_date,

CASE msdb..backupset.type

WHEN ‘D’ THEN ‘Database’

WHEN ‘L’ THEN ‘Log’

END AS backup_type,

msdb.dbo.backupset.backup_size,

msdb.dbo.backupmediafamily.logical_device_name,

msdb.dbo.backupmediafamily.physical_device_name,

msdb.dbo.backupset.name AS backupset_name,

msdb.dbo.backupset.description

FROM msdb.dbo.backupmediafamily

into <give table name>

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

Once the history backed up, we can execute below command for impacted database

EXEC msdb.dbo.sp_delete_database_backuphistory @database_name = N’<DBName>’

Hope this help in resolving database property error.

--

--