Hi, 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?
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.