Question

Is there a way to use my own number in a table like an auto-number; that is to automatically assign the next available to a new record. We have system ID numbers for each employee that I want to tie into this database. I just want the table to auto assign the next number.

Can I do this?
Could this be done with a mixture of numeric and alpha?
Could criteria be used, like Code A = certain set of numbers, Code B = another?

Was it helpful?

Solution

Of course you can, but you will have to design this yourself.

There are hundreds of ways of doing this but one way might be that you may have a parameters table with "nextQuote", "nextEmployeeNo", "nextJob"... of course your table design could have anything, including prefix example;

PARAMETERS
Prefix    Number
Q          1145
E            54
J           999

So now you can SELECT PreFix + MAX(Number) AS NextEmployee FROM Parameters WHERE Prefix = E

And in your code you can increment the number after dealing with it.

UPDATE Parameters SET Number = number + 1 WHERE Prefix = E 

If this isn't up to the job then hopefully it will get you thinking in how you can do something similar.

Hope this helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top