Avatar of obb-taurus
obb-taurus
Flag for Canada asked on

How can I generate unique IDs for different items inserted into a table

I'm working on an inventory application and a requirement is that the system generate a unique stock number for each item.  The only hitch is that there are several categories and each category needs to follow it's own numbering sequence.

To give a very bad example of what I'm trying to accomplish, in essence it would be like creating a table for each category and having an identity in each of those tables, this way whenever a new item is inserted into a specific category the numeric sequence would be consistent eg. 1001, 1002, 1003 etc.

I'm just looking for a better way to achieve what I've outlined in my above example.

Hope this make sense.

Thanks
Microsoft SQL Server.NET Programming

Avatar of undefined
Last Comment
ramrom

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Jim Horn

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
obb-taurus

ASKER
I see what you are saying, obviously the "business key" would be in a seperate field from the category and I would just concatenate them in my code for display or printing purposes.

Thanks for the help.
SOLUTION
ramrom

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes