Uploaded image for project: 'SonarTSQL'
  1. SonarTSQL
  2. SONARTSQL-215

Parse error for MERGE statements in CTE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: Parser
    • Labels:
      None

      Description

      It seems common table expression can be used together with MERGE statements.

      Following code should be parsed:

      WITH name_CTE (col1) AS (SELECT col1 FROM table1 WHERE col1 IS NOT NULL)
      MERGE table2 AS target USING name_CTE AS source ON (target.col1 = source.col1) WHEN MATCHED THEN UPDATE SET col2 = 1;
      

      See:
      https://docs.microsoft.com/en-us/sql/t-sql/queries/with-common-table-expression-transact-sql?view=sql-server-2017
      https://docs.microsoft.com/en-us/sql/t-sql/statements/merge-transact-sql?view=sql-server-2017

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                christophe.zurn Christophe Zurn
                Reporter:
                christophe.zurn Christophe Zurn
              • Votes:
                1 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Due:
                  Created:
                  Updated:
                  Resolved: