Generating a Number Sequence

By at February 07, 2008 10:14
Filed Under:

Here's a quick way to generate a sequence of numbers using T-SQL.

WITH NumberGen (number) AS
(   SELECT 0
    UNION ALL
    SELECT number + 1 FROM NumberGen WHERE number < 99)
-- extend as required 
SELECT Sequence = first.number * 100 + second.number 
FROM NumberGen first, NumberGen second
ORDER BY Sequence

And with LINQ using statements

foreach(int num in Enumerable.Range(0,10000)) // modify to taste 
{
    Console.WriteLine(num);
}

and using Expressions

from num in Enumerable.Range(0,10000)
select (num) 

Comments

3/13/2010 3:14:24 AM #

general electric cooktop

Hvala vam za dobar post puno hvala

general electric cooktop United States | Reply

3/20/2010 11:41:01 PM #

cheap prom Dresses

za dobar post puno hvala???

cheap prom Dresses People's Republic of China | Reply

4/23/2010 8:35:21 AM #

dearborn michigan

found your blog from a msn search. Added to my favs now. Cool.

dearborn michigan Belize | Reply

6/2/2010 5:50:27 PM #

howcast

Im no expert, but I think you just made the best point.  You obviously know a lot about what youre talking about, and I can really get behind that.  Thanks for being so upfront and so honest about the subject matter.  I really feel like I have a better understanding now.

howcast United States | Reply

6/3/2010 9:06:15 AM #

Recover Data From RAID 26

Fantastic blog!  I dont think Ive seen all the angles of this subject the way youve pointed them out.  Youre a true star, a rock star man.  Youve got so much to say and know so much about the subject that I think you should just teach a class about it...HaHa!

Recover Data From RAID 26 United States | Reply

6/11/2010 8:30:09 AM #

Starting a NUrsing Agency

Really Nice Blogpost. Would you thoughts if I take a little snippets of your write-up and naturally link it to your blogposts??

Starting a NUrsing Agency United States | Reply

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading