SQL Server Performance

Row lock in sql server 2000

Discussion in 'General Developer Questions' started by query4u, Feb 16, 2011.

  1. query4u New Member

    I want to generate unique trx id for that i am using different combination like date time, random number etc. i want to add incremental number to that so the number may not repeat. Incremental number i am storing in database, whenever i am generating number first i read this incremental number from database & attach to other number & then update the number by adding 1, i want to lock this row because if two transaction initiate at a same time both transaction will read same number, to avoid this i want to lock the row so at a time one transaction will read the row & update. Can anyone tell me how to do this?
  2. satya Moderator

    Why reinventing the wheel, why not use IDENTITY and specify the starting number you want to use. THe generation of numbers will be unique anyway.

Share This Page