I've got a column, called user_code char(3) that is used to store unique codes. The patterns are as follows
Character 1 is A-Z
Character 2 is 0-9,A-Z
Character 3 is 1-9,0,A-Z
So, the data starts at
Now, what I need to do is write a T-SQL statement that will tell me what the next available (ie unused) user_code can be. I wish I could just do a MAX(user_code) to find the most recently used one and then work out the next value in the sequence, but it's not that simple, as the user_codes assigned aren't in any meaningful order..
If you could help me with this, that'd be awesome. There are no constraints here really, if it means creating another lookup table with all the options in, then that's allowed, as long as the solution works!