Skip to content

[BUG] CTE doesnt work with update or insert, only select #596

Description

@magiva

Describe the bug

With mySource AS (
    Select top 1 statuscode 
    from account
)

UPDATE a
SET a.accountabc = 1
FROM account a
Where a.accountid = 233

I cant use the CTE as source for an Insert or Update.
Its happy with Select

Msg 40517, Level 16, State 1, Line 1
Keyword or statement option 'WITH' is not supported in this version of SQL Server.

To Reproduce
Query to reproduce the behavior:

With mySource AS (
    Select top 1 statuscode 
    from account
)

UPDATE a
SET a.accountabc = 1
FROM account a
Where a.accountid = 233

Expected behavior
use the source cte for update or insert

Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):

  • SQL 4 CDS edition: XrmToolBox
  • Results of SELECT @@VERSION:
  • Microsoft Dataverse - 9.2.24104.202
    
    SQL 4 CDS - 9.4.1.0
    Nov 28 2024 09:20:15
    Copyright © 2020 - 2024 Mark Carrington

Additional context
i do see it says not with this version, i should have put this as a feature request, sorry

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions