I am currently developing a travel insurance system. In my table, I have a transaction number which should increment by 1 every transaction. I tried using the code below in my previous development but primary column ID jumps (e.g. before insert row number is 10 after insert row number becomes 12). The travel insurance that I currently developing will be used entire Laos country. That means I am expecting concurrent users of +/- 200.
- ALTER PROCEDURE [dbo].[spAutoGenerateMotorCINo]
- AS
- BEGIN
- declare @ID int, @RefNumber nvarchar(15);
- Select @ID = ISNULL(Max(Cast(RIGHT(MotorInsuranceID, 15) as int)), 0) + 1 from tblMotorInsurance_eCI;
- Select RIGHT(cast(@ID as nvarchar), 9);
- END
Thank you in advance for any suggestions and recommendations.