Iteration counter in SQL select statement
Posted on 2008-10-17
I was wondering if anyone knows how to implement an iteration counter in SQL. Heres what Im talking about:
Imagine you have a table called IntegerNumbers with a single field called ii. The table is populated with values from 0 to 999999.
Now, in a select statement you can do this:
SELECT ii from IntegerNumbers WHERE ii between 1 and 10
Youll get a nice list of numbers out.
Basically, Im trying to do this but without the IntegerNumbers table. Perhaps a VALUES statement?
If you know how to do this Id sure appreciate hearing about it. A solution that will work in SQL 2005 would be preferred.