How to create a unique order number

Algorithmically speaking, how could I create a unique, readable, reasonably extended order number for a SQL Server column. The only requirement is that it refers to the customer number and can be easily repeated by phone.

Sort of:

  • Customer Number - XXXXXXXX - XXXXXXXX

RT65-XXXXXXXX-XXXXXXXX

How do I create XXXXXXXX? (Use random alphanumeric data, and then checking to see if this is a duplicate?)

and

What are the best methods / considerations when creating these types of numbers?

How did you do this in your application?

+3
source share
4 answers

Use the id column and pad with zeros.

.

CRC.

+1

, . ( ):

, ?

+1

It's stupid, but pretty straightforward, how about yyyymmddhhmsms

and use it with

RT65-XXXXXXXX-XXXXXXXX

+1
source

in php you can do the following:

<?php 
$stamp = strtotime("now");
$orderid = 'RT65-'.$stamp.'-'.$REMOTE_ADDR; 
$orderid = str_replace(".", "", $orderid); 
echo($orderid); 
?>
0
source

Source: https://habr.com/ru/post/1730256/


All Articles