Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Bug?】"An item with the same key has already been added" when applying UNION ALL inside the CROSS APPLY clause #348

Closed
hiroyuki0415 opened this issue Sep 5, 2023 · 0 comments

Comments

@hiroyuki0415
Copy link

SELECT b.businessunitid,
       child.guid
FROM   businessunit AS b CROSS APPLY (SELECT t.teamid AS guid
                                      FROM   team AS t
                                      WHERE  t.businessunitid = b.businessunitid
                                      UNION ALL
                                      SELECT s.systemuserid AS guid
                                      FROM   systemuser AS s
                                      WHERE  s.businessunitid = b.businessunitid) AS child;

When I run this SQL I get the following error:

An item with the same key has already been added

Thanks in advance for your support.

@MarkMpn MarkMpn closed this as completed in 4bddbab Sep 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant