I try to create and print invoices using web forms. I am trying to find the best recommended practice that I should use. Until now the practices I have are;
Create a table that will store "next invoice number" and then generate the next number using a stored procedure, something like "next number" + 1.
Store the previous number in the invoice DB table and then in my c# code increment it by one.
What I would like to avoid is use the SQL Server identity (auto increment) to generate the invoice number because of the gaps that may be happen (i have see in real life to occur ) but there are also articles that mention about these gaps. Why are there gaps in my IDENTITY column values? Identity increment is jumping in SQL Server database
My question is what is the recommended practice that I should follow to ensure that every invoice will get sequential unique invoice number?