Overview:
In my scenario a user uploads an excel file that needs to be written into database, I am allocating each uploaded file a batch_id   that batch_id is written in last column of each row of my table as shown in these pictures  [![File of User 1][1]][1]


[![enter image description here][2]][2]

With the help of this batch_id column I will be able to segregate that which rows belong to which document.(for example: if batch_id=1 than these 1000  rows belongs to document 1)

Problem:
Consider two users user1 and user2 executing this stored procedure at the same time while Stored Procedure  is writing batch_id=1 in all the rows which belong to document1,at the same time rows belonging to  document2 will gets inserted thus causing a conflict wether to write batch_id=1 or batch_id=2 in the rest of remaining rows.


Imperfect  Solution:
To Execute Stored Procedure on one document at a time,when its done execute it on document 2 but this will let the user to wait until the current execution finishes which i don't want to  happen.
 


  [1]: https://i.sstatic.net/Agg6I.png
  [2]: https://i.sstatic.net/WIlwL.png