To learn more about the vulnerability, go to CVE-2018-8273.
You must run this script if you use Query Store and you are updating from SQL Server 2017 Cumulative Update 2 (CU2) directly to SQL Server 2017 Cumulative Update 3 (CU3) or any later Cumulative Update. Executing this script is not needed if you have previously installed SQL Server 2017 Cumulative Update 3 (CU3) or any later SQL Server 2017 Cumulative Update.
SET NOCOUNT ON;DROP TABLE IF EXISTS #tmpUserDBs;SELECT [database_id], 0 AS [IsDone]INTO #tmpUserDBsFROM master.sys.databasesWHERE [database_id] > 4 AND [state] = 0 -- must be ONLINE AND is_read_only = 0 -- cannot be READ_ONLY AND [database_id] NOT IN (SELECT dr.database_id FROM sys.dm_hadr_database_replica_states dr -- Except all local Always On secondary replicas INNER JOIN sys.dm_hadr_availability_replica_states rs ON dr.group_id = rs.group_id INNER JOIN sys.databases d ON dr.database_id = d.database_id WHERE rs.role = 2 -- Is Secondary AND dr.is_local = 1 AND rs.is_local = 1)DECLARE @userDB sysname;WHILE (SELECT COUNT([database_id]) FROM #tmpUserDBs WHERE [IsDone] = 0) > 0BEGIN SELECT TOP 1 @userDB = DB_NAME([database_id]) FROM #tmpUserDBs WHERE [IsDone] = 0 -- PRINT 'Working on database ' + @userDB EXEC ('USE [' + @userDB + '];DECLARE @clearPlan bigint, @clearQry bigint;IF EXISTS (SELECT [actual_state] FROM sys.database_query_store_options WHERE [actual_state] IN (1,2))BEGIN IF EXISTS (SELECT plan_id FROM sys.query_store_plan WHERE engine_version = ''14.0.3008.27'') BEGIN DROP TABLE IF EXISTS #tmpclearPlans; SELECT plan_id, query_id, 0 AS [IsDone] INTO #tmpclearPlans FROM sys.query_store_plan WHERE engine_version = ''14.0.3008.27'' WHILE (SELECT COUNT(plan_id) FROM #tmpclearPlans WHERE [IsDone] = 0) > 0 BEGIN SELECT TOP 1 @clearPlan = plan_id, @clearQry = query_id FROM #tmpclearPlans WHERE [IsDone] = 0 EXECUTE sys.sp_query_store_unforce_plan @clearQry, @clearPlan; EXECUTE sys.sp_query_store_remove_plan @clearPlan; UPDATE #tmpclearPlans SET [IsDone] = 1 WHERE plan_id = @clearPlan AND query_id = @clearQry END; PRINT ''- Cleared possibly affected plans in database [' + @userDB + ']'' END ELSE BEGIN PRINT ''- No affected plans in database [' + @userDB + ']'' ENDENDELSEBEGIN PRINT ''- Query Store not enabled in database [' + @userDB + ']''END') UPDATE #tmpUserDBs SET [IsDone] = 1 WHERE [database_id] = DB_ID(@userDB)END
How to obtain and install the update
Method 1: Windows Update
Method 2: Microsoft Update Catalog
Method 3: Microsoft Download Center
The following file is available for download from the Microsoft Download Center:
Download the package now
Release Date: August 14, 2018
For more information about how to download Microsoft support files, click the following article number to go to the article in the Microsoft Knowledge Base:
Microsoft scanned this file for viruses by using the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to it.
Method 4: For SQL Server 2017 on Linux platforms and containers
- For information on obtaining and installing this update on Linux Operating Systems or Docker Containers, see:
Important If you install a language pack after you install this update, you must reinstall this update. Therefore, we recommend that you install any language packs that you need before you install this update. For more information, see Add language packs to Windows.
The English (United States) version of this software update installs files that have the attributes that are listed in the following tables. The dates and times for these files are listed in Coordinated Universal Time (UTC). The dates and times for these files on your local computer are displayed in your local time together with your current daylight saving time (DST) bias. Additionally, the dates and times may change when you perform certain operations on the files.