Hello,
It might be a small issue but I need to generate the next invoice number from the field InvoiceNo in the table Invoices.
My problem is a concurrency one since there are more operators adding invoices at the same time and sometimes we have duplicate numbers as yielded by Max(InvoiceNo).
I can't use an Identity field because the InvoiceNo range varies and starts from 1 each year.
The Number is added when the invoice is validated, not when inserted into the table.
It's a common practice to start each year numbering documents with 1.
(Invoices, accounting notes, etc...)
So there's nothing special to provide: 1,2,... and the following year: 1,2,3,...
Thanks!
Sequences seem to be the answer (I still have some 2008R2 servers but we will upgrade).
They also have the Restart option
I didn't know they exist.
Thank you again, Daniel