the application should generate a unique 16-digit order number (includes the type of delivery (1 digit) that the user has opted for, Product id (7 digits), and the order number (8 digits)) as soon as the order is placed by the customer.
the application should generate a unique 16-digit order number (includes the type of delivery (1 digit) that the user has opted for, Product id (7 digits), and the order number (8 digits)) as soon as the order is placed by the customer.
And with which part of this requirement do you have issues? Should it be a numeric or a varchar "number"? A order can have only one product, not more? I ask because the product id should be part of the unique ID.
Can you post some samples?
Can you post some samples?
I would not think so. I mean this smells like an assignment/interview question, with no real-world data to help with the task.
The way to do what you describe is to create 3 fields, delivery, product id, and order number. Then create a computed field which concatenates the values into a single string.
Hi,
Because this 16-digit order number is completely generated by the combination of the contents of the other three columns, whether it is unique depends on the definition of other columns, and at least one column needs to be defined as unique.
You can consider the way to set up a computed column, whether to add a computed column when creating a table or add a computed column to an existing table. But the specific implementation needs to be based on your table definition, you did not provide it.
The order number is usually unique and unchangeable., it is recommended to make the computed column persisted without having to recalculate each time it is accessed.
Or consider creating a view based on this table and generating the new order number column.
14 people are following this question.