I am using the Function in stored procedure , procedure contain transaction and update the table and insert values in the same table , while the function is call in procedure is also fetch data from same table.
i get the procedure is hang with function.
Can have any solution for the same?
If I’m hearing you right, you’re talking about an insert BLOCKING ITSELF, not two separate queries blocking each other.
We had a similar problem, an SSIS package was trying to insert a bunch of data into a table, but was trying to make sure those rows didn’t already exist. The existing code was something like (vastly simplified):
This ended up blocking itself because the select on the WHERE NOT EXISTS was preventing the INSERT from occurring.
We considered a few different options, I’ll let you decide which approach works for you:
In our case, we already had the data in a temp table, so we simply deleted the rows we didn’t want inserted, and did a simple insert on the rest.