when I execute a query in Azure SQL database, return error "Msg 8624, Level 16, State 22"

李能江 NengJiang Li 1 Reputation point
2021-01-27T07:02:09.467+00:00

when I execute a query in Azure SQL database, return error "Msg 8624, Level 16, State 22".
the sql ran well before 2021-01-24,i never chagne it.

Msg 8624, Level 16, State 22, Line 8
Internal Query Processor Error: The query processor could not produce a query plan. For more information, contact Customer Support Services.

set QUOTED_IDENTIFIER ON  
go  
DECLARE @DWEndDate DATETIME = '9999-12-31 00:00:00.000'  
  
DROP TABLE IF EXISTS #Dim_D365_Location  
  
-- Create temp table  
SELECT DISTINCT  
          
            D.DATAAREAID AS ENTITYCODE,  
                D.INVENTLOCATIONID,  
                L.[NAME] AS INVENTLOCATIONNAME,  
                D.INVENTSITEID AS SITEID,  
                S.[NAME] AS SITENAME,  
                D.WMSLOCATIONID,  
                D.INVENTSTATUSID,  
                D.LICENSEPLATEID,  
                D.INVENTBATCHID,  
  
           'N/A' AS CreatedBy,  
            CAST('1753-01-01 00:00:00.000' AS datetime) AS CreatedDate,  
            'N/A' AS ModifiedBy,  
            CAST('1753-01-01 00:00:00.000' AS datetime) AS ModifiedDate,  
            CASE WHEN D.DWCurrentFlag = 'N'  
                                OR L.DWCurrentFlag = 'N'  
                             OR S.DWCurrentFlag = 'N'  
                         THEN 'N'  
                   ELSE 'Y' END AS DWCurrentFlag,  
  
        -- Select Max UpdateDate to construct the # table  
                (  
                        SELECT MAX(DWUpdateDate) AS DWUpdateDate  
                        FROM (  
                                SELECT D.DWInsertDate AS DWUpdateDate UNION  
                                  
                                SELECT D.DWEndDate AS DWUpdateDate UNION  
                                  
                                SELECT L.DWInsertDate AS DWUpdateDate UNION  
                                SELECT D.DWUpdateDate AS DWUpdateDate UNION  
                                SELECT L.DWUpdateDate AS DWUpdateDate UNION  
                                SELECT L.DWEndDate AS DWUpdateDate UNION  
                                SELECT S.DWInsertDate AS DWUpdateDate UNION  
                                SELECT S.DWUpdateDate AS DWUpdateDate UNION  
                                SELECT S.DWEndDate AS DWUpdateDate  
                           ) a WHERE DWUpdateDate <> @DWEndDate  
                ) AS DWUpdateDate  
INTO #Dim_D365_Location  
  
FROM [dbo].[Filter_STG_D365_SWIInventDimStaging] D  
INNER JOIN [dbo].[Filter_STG_D365_SWIInventLocationStaging] L  
            ON D.INVENTLOCATIONID = L.INVENTLOCATIONID  
                AND D.DATAAREAID = L.DATAAREAID  
                AND D.PARTITION = L.PARTITION  
INNER JOIN [dbo].[Filter_STG_D365_SWIInventSiteStaging] S  
            ON D.INVENTSITEID = S.SITEID  
                AND D.DATAAREAID = S.DATAAREAID  
                AND D.PARTITION = L.PARTITION  
  
  
  
---------- CDC Where Clause----------  
WHERE  
        (  
                SELECT MAX(DWUpdateDate) AS DWUpdateDate  
                FROM (  
                        SELECT D.DWInsertDate AS DWUpdateDate UNION  
                        SELECT D.DWEndDate AS DWUpdateDate UNION  
                        SELECT L.DWInsertDate AS DWUpdateDate UNION  
                        SELECT D.DWUpdateDate AS DWUpdateDate UNION  
                        SELECT L.DWUpdateDate AS DWUpdateDate UNION  
                        SELECT L.DWEndDate AS DWUpdateDate UNION  
                        SELECT S.DWInsertDate AS DWUpdateDate UNION  
                        SELECT S.DWUpdateDate AS DWUpdateDate UNION  
                        SELECT S.DWEndDate AS DWUpdateDate  
                ) a WHERE DWUpdateDate <> @DWEndDate  
        ) > (  
                SELECT LastUpdatedTime  
                FROM LOG_LastUpdatedTime_Backup  
                WHERE TableName = 'Dim_D365_Location'  
        )  


  
Azure SQL Database
{count} votes

1 answer

Sort by: Most helpful
  1. 李能江 NengJiang Li 1 Reputation point
    2021-01-28T07:55:50.393+00:00

    select @@version

    Microsoft SQL Azure (RTM) - 12.0.2000.8 Jan 4 2021 23:33:42 Copyright (C) 2019 Microsoft Corporation

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.