Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Lottery Guesses Numbers

Author  Topic 

noamg
Posting Yak Master

215 Posts

Posted - 2011-11-08 : 10:37:19
hi,

I need to create table with all the legal combinations.
There are 6 numbers, each one between 1-49, without duplicate.
Total number of rows: 49x48x47x46x45x44 = 10,068,347,520
what is the best fast algorithm to do this table ?
thanks


Noam Graizer

uberman
Posting Yak Master

159 Posts

Posted - 2011-11-08 : 11:37:17
Adapt http://sqlserverdiaries.com/blog/index.php/2011/03/generate-lottery-ticket-combinations/

6 ball 1-49 lottery, 13M+ rows ran in about 1min40sec on my (quite old) box

(There might be a quicker way though...)
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-11-08 : 12:00:57
What's the point of storing it in a table?
Go to Top of Page
   

- Advertisement -