473,396 Members | 2,106 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Selecting alphanumeric combinations that do not exist already intable?????

rbr
Hello all, I have an odd requirement. I have a column with a system
generated username that is a 6 character, alphanumeric, field. These
usernames are randomly generated by code. I need to create a stored
procedure that will return all combinations that are not already
being
used. Maybe the result of still trying to wake-up from a long
weekend.
But, I cannot think of an easy way to do this.

Any help would be greatly appreciated.
Best regards,
rbr
Mar 24 '08 #1
4 4282
rbr (ry********@gmail.com) writes:
Hello all, I have an odd requirement. I have a column with a system
generated username that is a 6 character, alphanumeric, field. These
usernames are randomly generated by code. I need to create a stored
procedure that will return all combinations that are not already
being
used. Maybe the result of still trying to wake-up from a long
weekend.
But, I cannot think of an easy way to do this.
All? There are 2176782336 combination, so unless a large number of the
combinations are already in use, that will be a huge result set.

I started to compose a solution that would return 1000 random codes
currently not, but I realised that it was not trivial to write. So I
abandoned it for the moment, as I may not solve the right problem for
you.

Of course, if you store all 2176782336 combinations in a table, it's
trivial. But would be over 20 GB in size... (Have to count with some
8-9 bytes overhear per row.)

Anyway, if you could be a little more specific, that would be nice.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 24 '08 #2
rbr
On Mar 24, 4:15 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
rbr (ryankbr...@gmail.com) writes:
Hello all, I have an odd requirement. I have a column with a system
generated username that is a 6 character, alphanumeric, field. These
usernames are randomly generated by code. I need to create a stored
procedure that will return all combinations that are not already
being
used. Maybe the result of still trying to wake-up from a long
weekend.
But, I cannot think of an easy way to do this.

All? There are 2176782336 combination, so unless a large number of the
combinations are already in use, that will be a huge result set.

I started to compose a solution that would return 1000 random codes
currently not, but I realised that it was not trivial to write. So I
abandoned it for the moment, as I may not solve the right problem for
you.

Of course, if you store all 2176782336 combinations in a table, it's
trivial. But would be over 20 GB in size... (Have to count with some
8-9 bytes overhear per row.)

Anyway, if you could be a little more specific, that would be nice.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
I have considered the speed and space issues. Unfortunately, there are
over 14 million usernames currently in use and another 10 million
reserved for currently inactive customers. The process of generating
names and checking if they are taken is getting tougher. The idea my
boss had was to create a table (once) of unused usernames and randomly
pick one from the list each time. If this is not feasible (you all
make very good points) I would be more than happy to tell him so.
However, I figured it would be worth investigating before saying it
was impossible.

Best regards,

rbr
Mar 25 '08 #3
rbr (ry********@gmail.com) writes:
I have considered the speed and space issues. Unfortunately, there are
over 14 million usernames currently in use and another 10 million
reserved for currently inactive customers. The process of generating
names and checking if they are taken is getting tougher. The idea my
boss had was to create a table (once) of unused usernames and randomly
pick one from the list each time. If this is not feasible (you all
make very good points) I would be more than happy to tell him so.
However, I figured it would be worth investigating before saying it
was impossible.
Impossible it isn't. But it's definitely a waste of disk space.

Even if you have 24 million codes already taken, that's only a little
more than 1% of the total space consumed, so I think that if every time
you need a code, generate a random code, check if it is in use this
should be efficient enough. For about each 10000 customer you will have
to generate three codes before you have an unused code.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Mar 25 '08 #4
rbr
Very good. Thank you all very much for the feedback. It is much
appreciated.

Best regards,

rbr


On Mar 25, 4:30 pm, Erland Sommarskog <esq...@sommarskog.sewrote:
rbr (ryankbr...@gmail.com) writes:
I have considered the speed and space issues. Unfortunately, there are
over 14 million usernames currently in use and another 10 million
reserved for currently inactive customers. The process of generating
names and checking if they are taken is getting tougher. The idea my
boss had was to create a table (once) of unused usernames and randomly
pick one from the list each time. If this is not feasible (you all
make very good points) I would be more than happy to tell him so.
However, I figured it would be worth investigating before saying it
was impossible.

Impossible it isn't. But it's definitely a waste of disk space.

Even if you have 24 million codes already taken, that's only a little
more than 1% of the total space consumed, so I think that if every time
you need a code, generate a random code, check if it is in use this
should be efficient enough. For about each 10000 customer you will have
to generate three codes before you have an unused code.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

Mar 26 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Shozi | last post by:
Dear All, My project is basically about the personal record keeping of user's data. Now user can customize their data entry form by adding/removing the desired fields for personal information...
36
by: rbt | last post by:
Say I have a list that has 3 letters in it: I want to print all the possible 4 digit combinations of those 3 letters: 4^3 = 64 aaaa
3
by: Jonathan | last post by:
Hi all! For a match schedule I would like to find all possible combinations of teams playing home and away (without teams playing to themselves of course). I now the simple version works...
7
by: Fernando Rodríguez | last post by:
Hi, How can I know if a string only has alfanumeric chars? Thanks
6
by: nycjay | last post by:
I am tring to clean up data in some of our fields. The requirement is to only have letter (a-z,A-Z) and number (0-9) characters in the field... So, if we select from the non-cleaned-up field, we...
13
by: lane straatman | last post by:
I'm trying to figure out what data type is appropriate to represent a card in a game. The idea that I thought was going to work was a struct, foo, with two integer fields and two fields of char...
2
by: The Frog | last post by:
Hello everyone, I am trying to find way of writing an SQL query that can produce missing record combinations across a many to many type setup in Access. The three tables used are as follows:...
1
by: William Leith | last post by:
I want to allow visitors to type braille on my web site. This would require users typing different combinations of the s, d, f, j, k and l keys that would correspond to letters of the alphabet (e.g,...
3
by: rpradeepa | last post by:
Hi How to give alphanumeric validation for textbox in VBA for ms access already the textboxvalue is filled with "6hy754" textbox="6hy754" I have to check whether the value is alphanumeric...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.