KB4522126 - FIX: You may receive wrong results when you query sys.database_scoped_configurations in SQL Server 2016

Symptoms

When you run a query that inserts the output of sys.database_scoped_configurations to a table variable or temporary table in Microsoft SQL Server 2016, and then select from that table variable or temporary table as seen in the example below, you may notice that there is only one entry for each database.

DROP TABLE IF EXISTS #h

CREATE 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

or

DECLARE @database_scoped_configurations TABLE(x INT);

INSERT INTO @database_scoped_configurations

SELECT configuration_id

FROM sys.database_scoped_configurations;

SELECT * FROM @database_scoped_configurations

Status

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.

Resolution

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:

Workaround

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_configurations

SELECT TOP 100 configuration_id

FROM sys.database_scoped_configurations

References

Learn about the terminology that Microsoft uses to describe software updates.

Need more help?

Expand your skills
Explore Training
Get new features first
Join Microsoft Insiders

Was this information helpful?

Thank you for your feedback!

Thank you for your feedback! It sounds like it might be helpful to connect you to one of our Office support agents.

×