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

[FEATURE] OUTPUT needed so i can record the guids of new records to create relationships #597

Open
magiva opened this issue Dec 3, 2024 · 4 comments

Comments

@magiva
Copy link

magiva commented Dec 3, 2024

Is your feature request related to a problem? Please describe.
during an update or insert i want to get the record id of each new row so i can then update the source data rows, essentially creating a relationship to the new records.

Describe the solution you'd like
INSERT INTO target_table (name, address)
OUTPUT inserted.row_guid, source_table.source_guid

Describe alternatives you've considered
i used creation date to see the records id created and then used that data to manually align (it was late :))

Additional context
Add any other context or screenshots about the feature request here.

@MarkMpn
Copy link
Owner

MarkMpn commented Dec 3, 2024

Thanks for the suggestion!

You can get the ID of newly inserted records using @@IDENTITY which might get you what you need, e.g.

INSERT INTO account (name) VALUES ('New Account')

INSERT INTO contact (firstname, lastname, parentcustomerid) VALUES ('Mark', 'Carrington', @@IDENTITY)

@magiva
Copy link
Author

magiva commented Dec 4, 2024

its good idea but i thought this is only for 1 record as it returns only the last insert.
wouldnt work for multiple inserts i believe. happy to be wrong though :)
i think my better option would be to create a temp table in dataverse to handle it

@MarkMpn
Copy link
Owner

MarkMpn commented Dec 4, 2024

Indeed, using OUTPUT would be a good enhancement but flagging @@IDENTITY as a possible workaround for now when you are working with single records.

@magiva
Copy link
Author

magiva commented Dec 4, 2024 via email

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

2 participants