Skip to content

[BUG] Insert into Temporary table fails with ids #670

Description

@SlckCam

Describe the bug
Inserting two ids in a temporary table with a select fails with the following error : "Msg 120, Level 15, State 1, Line 24
The select list for the INSERT statement contains fewer items than the insert list. The number of SELECT values must match the number of INSERT columns."

To Reproduce
Query to reproduce the behavior (custom table replaced with a "theoretical Account table")

CREATE TABLE #PersistedAccount (
    Accountid UNIQUEIDENTIFIER,
    persisted_Accountid UNIQUEIDENTIFIER
)

INSERT INTO #PersistedAccount (Accountid, persisted_Accountid)
SELECT Account.Accountid, Account2.Accountid
from Account Account 
    left join Account Account2 on Account2.Accountid = Account.Accountid and Account2.localid = Account.localid
where Account2.Accountid = (select top 1 AccountFirst.Accountid from Account AccountFirst where AccountFirst.Account_id = Account.Account_id and AccountFirst.localid = Account.localid order by AccountFirst.Accountid)
and Account.categorie_id is not null
and Account2.categorie_id is not null

Expected behavior
The two account Id should be inserted as a row in the temporary table

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

Environment (please complete the following information):

  • SQL 4 CDS edition: XrmToolBox version 9.6.1
  • Results of SELECT @@VERSION: Microsoft SQL Azure (RTM) - 12.0.2000.8 Apr 9 2025 07:13:50 Copyright (C) 2024 Microsoft Corporation

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