sql - How to get Unique Value from a table for different sessions -


I have a process that creates unique account ID while Accounts When creating

  • Maximum Account ID is stored in another table ( Table :: MaxAccountID ).
  • Example: Account ID :: MG110000021 (110000021, we are getting from the MaxAccountID table)

    For example: max account id p>

    We received TABLOCKX for unique code id Because the same SP is being called during a fraction of a second in many sessions.

    Therefore each session will receive TABLOCKX with the unique account id .

    This does not solve my problem, however, we also account ID for the same (duplicate) different sessions.

      SELECT @OutPutID = Account ID from MaxAccountID (TABLOCKX) UPDATE MAXAccountID SET AccountID = AccountID +1   

    Account ID value.

      Start from the BEGIN transfer EXEC GetMax_AccountID @OutPutID account INFO included (------------ COMMIT TRANSACTION Finally start the catch rollback transfer end capture   

    GetMax_AccountID are included in the form of output para as output para

      SELECT @OutPutID = AccountAd, from MaxAccountID With (TABLOCKX) UPDATE MAXAccountID SET AccountID = AccountID +1    

    Maybe it will help The value will be directly back.

      UPIDATE MAXID_Task SET ID = ID + 1 OUTPUT If you need it in the variable:  
      DECLARE @Result TABLE (ID int) Update MAXID_Task SET ID = ID + 1 OUTPUT In the deleted I, select the @ result @OutPutID = result @ id    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -