Hi Experts,

1) This may not exactly be a ColdFusion question, but I am going to program it in CF v10 and you guys are very smart! SQL Guys too!!!!

Problem: I need to generate** in a random sequence **a list if all possible 4 digit numbers only using the set of digits (1,2,3,4,5)

ex: 1234, 4455, 5555, 1111.

I'm not sure how to do this best. I could

- generate a random 4 digit number from the set of (1,2,3,4,5). I think I did that somewhere before in a CAPTCHA routine.

- Search a table to make sure I didn't pick it already. If I did retry otherwise store the number in the next slot of the table.

But at the end, it will be like looking for a needle in a haystack when I only have a few possibilities left?

2) FYI. I also use SQL Server 2012 and this could be part of the solution.

-- Insert rows (Sequential number column, random column)

- Select all rows order by random column

**3) ColdFusion guys: How do I generate the numbers sequentially between 1111 - 5555 only using the digits 1,2,3,4,5?**

Any advise?

Thanks in advance,

hefterr

> So I was thinking of just loading a test table with all the possible sequential values

That's what I was suggesting in step #1. The query above should generate all the numbers w/just a few lines of SQL. To order the results randomly, just add an ORDER BY NewID() to the query. If you want to save it to a table, just add an "INSERT INTO ..." in front of the SELECT.

Edit: Something like thisOpen in new window