Saturday, 14 September 2013

Generate non-repetitive number ever

Generate non-repetitive number ever

I have a SQLServer database and table Invoice (InvoiceID ,InvoiceNumber ,
Amount , Comment) in it , which InvoiceNumber is generated from [InvoiceID
from Invoice + CompanyId in CompanyTable] ,where InvoiceID and CompanyID
are auto increment , I want user to export data in xml file and then
import it when he want , but what if user exported all data and re-install
the program, then imported all data, then import a new record from the
program which InvoiceID and CompanyId are begin from 1 again, so
InvoiceNumber will repeat again , so how to avoid this , I have thought a
lot ,I thought about none-repetitive number for ever , I found out that if
I use timestamp for InvoiceNumber it will never be duplicated , but its
too long for InvoiceNumber and annoying for search, is there any other
solutions?

No comments:

Post a Comment