SQL Server – Inserts Using the Cursor with Full Analysis of Table Blocked Table Blocking Queries


Technical details: Microsoft SQL Server Web (64 bit)
14.0.3023.8

I'm using the slider to add a lot of inserts.

Something like

Insert in the client

But before insertion I check if the entry does not exist something like

Select * in the client where ReferenceNo <> 'New & # 39;

The problem is that while the cursor is running for 1 minute, all other queries that require a client table are blocked.

If possible, I do not want to activate Snapshot. Hundreds of procedures / queries use the Client table and have all been blocked during insertion.

All ideas are appreciated.

Why do I use Cursor because the real query is a bit complicated for me

https://sqliteonline.com/#fiddle-5bf5599274b3f51ljor6swe7

In addition, there is a procedure called ID_Gen which is a procedure that calls a sequence and I can not use Identity because of some business rules.