3
Answers

Procedure to generate serial number from a range in a table

P G

P G

13y
3.3k
1
I have table which contains order number and corresponding Serial number range for those order.

I need to create another table where I can store order number with a list of all serial numbers for that order.

Table I have:

Order No        SerialNoStart        SerialNoEnd
1                        55                        66
2                        77                        90      
3                        233                       237

Table I need to generate from above table:

Order No        SerialNumber
1                        55
2                        56
3                        57
|                        |
|                        |       
3                        66
4                        77
4                        78
|                        |
|                        |
4                        90
5                        233
5                        234
|                        |
|                        |
5                        237

It would be great if anyone can show me how to get this done. I dont care if it's done using function, procedure, etc. whatever is easy.

Thanks.
Answers (3)