Hai all,
thank you for helping me,
Yes I would like to reverse from a result set 2,3,5,7,11,13,17,19,23,29, would like to be returned 29,23,19,17,13,11,7,5,3,2 instead.
and perhaps I've got the answer from @anthony.green and @tbailey 19088.
Thank you very much.
I will try the Syntax..
I've not executed it but the original code will do it. Instead of calling it with a 1, just call it with a 2. And, seriously, instead of calling a proc every time you need Prime Numbers, which don't change, use the proc just once to build a table of Prime Numbers. Your code that needs the prime numbers will be faster and easier to write.
If you do insist on using a proc for this instead of such a "Helper Table", at least find a Prime Number generator that will be fast. Use Peter "Peso" Larsson's code from the following link. It will generate prime numbers up to 1,000,000 in only 2 to 4 seconds depending on your machine and cache. It's the one that "Peso" posted with "This is about as easy and fast as possible, set-based" in it.
Unless you're in the business of discovering new primes, don't bother doing any prime calculations at all... The interwebs has no shortage of list of pre-calculated primes.
This site alone covers you from 0 to 1,000,000,000,000... http://www.primos.mat.br/indexen.html
'Zactly but the problem with WebSites like that is that you have to unzip multiple files to get what you need. If you use Peter "Peso" Larsson's code that I provided at the link a bit above, it'll only take a couple of seconds instead of downloading, unpacking, importing, etc. It takes 2-4 seconds for Peter's code to do the Primes up to 1,000,000 and is pretty linear and I've tested it at 20-40 seconds for the first 10,000,000.