SQL Hold Table Identity column generation and insert while concurrent record inserted
up vote
0
down vote
favorite
I am having issue while calling stored procedures concurrently. I'll try the explain the scenario.
ParentSP --> main stored procedure -- is calling 2 child stored procedures one by one --> Child1 and Child2
Child1 inserts record into the table and get ID column value of
IDENT_CURRENT()
child2 creates record in another table with values of table1 based on Identity column fetched from child1
What's happening here / issue is: first record is being updated with values of second record.
I think the issue is while child2 inserting record the ID selected from child1 is getting updated by concurrent second call. So is it possible if I can lock first table until child2 execution completed so that child1 doesn't generate new ID?
Please feel free to ask for clarification.
sql-server sql-server-2016
add a comment |
up vote
0
down vote
favorite
I am having issue while calling stored procedures concurrently. I'll try the explain the scenario.
ParentSP --> main stored procedure -- is calling 2 child stored procedures one by one --> Child1 and Child2
Child1 inserts record into the table and get ID column value of
IDENT_CURRENT()
child2 creates record in another table with values of table1 based on Identity column fetched from child1
What's happening here / issue is: first record is being updated with values of second record.
I think the issue is while child2 inserting record the ID selected from child1 is getting updated by concurrent second call. So is it possible if I can lock first table until child2 execution completed so that child1 doesn't generate new ID?
Please feel free to ask for clarification.
sql-server sql-server-2016
3
Ident_current() is dangerous in a multi user environment, no? Instead of ident_current() try using output inserted.id.
– Cetin Basoz
Nov 9 at 9:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am having issue while calling stored procedures concurrently. I'll try the explain the scenario.
ParentSP --> main stored procedure -- is calling 2 child stored procedures one by one --> Child1 and Child2
Child1 inserts record into the table and get ID column value of
IDENT_CURRENT()
child2 creates record in another table with values of table1 based on Identity column fetched from child1
What's happening here / issue is: first record is being updated with values of second record.
I think the issue is while child2 inserting record the ID selected from child1 is getting updated by concurrent second call. So is it possible if I can lock first table until child2 execution completed so that child1 doesn't generate new ID?
Please feel free to ask for clarification.
sql-server sql-server-2016
I am having issue while calling stored procedures concurrently. I'll try the explain the scenario.
ParentSP --> main stored procedure -- is calling 2 child stored procedures one by one --> Child1 and Child2
Child1 inserts record into the table and get ID column value of
IDENT_CURRENT()
child2 creates record in another table with values of table1 based on Identity column fetched from child1
What's happening here / issue is: first record is being updated with values of second record.
I think the issue is while child2 inserting record the ID selected from child1 is getting updated by concurrent second call. So is it possible if I can lock first table until child2 execution completed so that child1 doesn't generate new ID?
Please feel free to ask for clarification.
sql-server sql-server-2016
sql-server sql-server-2016
edited Nov 9 at 11:30
marc_s
568k12810991249
568k12810991249
asked Nov 9 at 9:06
BeingJaaved
11
11
3
Ident_current() is dangerous in a multi user environment, no? Instead of ident_current() try using output inserted.id.
– Cetin Basoz
Nov 9 at 9:20
add a comment |
3
Ident_current() is dangerous in a multi user environment, no? Instead of ident_current() try using output inserted.id.
– Cetin Basoz
Nov 9 at 9:20
3
3
Ident_current() is dangerous in a multi user environment, no? Instead of ident_current() try using output inserted.id.
– Cetin Basoz
Nov 9 at 9:20
Ident_current() is dangerous in a multi user environment, no? Instead of ident_current() try using output inserted.id.
– Cetin Basoz
Nov 9 at 9:20
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53222693%2fsql-hold-table-identity-column-generation-and-insert-while-concurrent-record-ins%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
Ident_current() is dangerous in a multi user environment, no? Instead of ident_current() try using output inserted.id.
– Cetin Basoz
Nov 9 at 9:20