In the front end when the client enters a quantity of 100/200 of a particular medicine, need to generate unique serial numbers for the batches which have validations of what to include/exclude and save 100/200 rows with all the details of batches along with a unique serial number.
For example: if I'm ordering a quantity of
100 and press on "Generate serial numbers" button and the validation is like need to include
'ABCDEFGHIJKL2589' (just an example can vary what to include).
Variables here are the
Quantity and
Alphanumerics to be included to generate serial numbers. (which are dynamic)
Serial number max length is 20.
Few more examples
There is a form in the front end to select the Alphabets and Numbers to be included in the serial number generation.It can either be UpperCase or LowerCase but cant be both and numbers from 0-9. No special characters.
If i need 10 Qty( batches) then using the selected letters and numbers i will generate 10 different serial numbers(in this example i might have selected 'A,B,C,D,1,2,3' in front end).
A,AB,AC,AD,AD1,AB23 etc
If i need If i need 20 Qty( batches) then using the selected letters and numbers i will generate 20 different serial numbers.(in this example i might have selected 'G,H,A,B,5,0,3' in front end).
GHA,BA5,GHAB503 etc
What I have tried:
trying few solutions using
newid()
but m not getting how to generate unique serial number using the selected Alphanumerics and which has to be unique over all the batches going forward.