When you run a query that inserts the output ofsys.database_scoped_configurations to a table variable or temporary table in Microsoft SQL Server 2016, and then select from that table variable or temporarytable as seen in the example below, you may notice that there is only one entry for each database.
DROP TABLE IF EXISTS #hCREATE TABLE #h(configuration_id INT, name sysname, value SQL_VARIANT, value_for_secondary SQL_VARIANT)INSERT INTO #h(configuration_id, name, value,value_for_secondary)SELECT * FROM sys.database_scoped_configurations D'SELECT * FROM #h H
DECLARE @database_scoped_configurations TABLE(x INT);INSERT INTO @database_scoped_configurationsSELECT configuration_idFROM sys.database_scoped_configurations;SELECT * FROM @database_scoped_configurations
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
This issue is fixed in the following cumulative update for SQL Server:
About cumulative updates for SQL Server:
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
To work around this issue, you can add a TOP clause on the SELECT part of your insert to get the correct result. Here is an example:
DECLARE @database_scoped_configurations TABLE(x INT);INSERT INTO @database_scoped_configurationsSELECT TOP 100 configuration_idFROM sys.database_scoped_configurations