Assume that you use the Policy-Based Management policy to manage Microsoft SQL Server 2016. After you install the Cumulative Update 2 (CU2) for SQL Server 2016 Service Pack 1 (SP1), the policy may function abnormally. For example, you have the policy to evaluate whether the name contains specific characters when you create a new stored procedure. After you install CU2, even if the name is valid, you may still not able to create the stored procedure, and you receive an error message that resembles the following:

Msg 515, Level 16, State 2, Procedure ProcedureName, Line LineNumber [Batch Start Line LineNumber ]

Cannot insert the value NULL into column 'target_query_expression', table 'msdb.dbo.syspolicy_policy_execution_history_details_internal'; column does not allow nulls. INSERT fails.


This issue is fixed in the following cumulative updates for SQL Server:

       Cumulative Update 2 for SQL Server 2017

       Cumulative Update 6 for SQL Server 2016 SP1

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:

Latest cumulative update for SQL Server 2017

Latest cumulative updates for SQL Server 2016

More information

See Administer Servers by Using Policy-Based Management.


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


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?

What affected your experience?

Thank you for your feedback!