Technical Article

TSQL that lists all numbers from 1..100

,

Run this from any database since it does not use any existing table!

Answer:

SELECT (10*a.x + b.y) + 1 as z

FROM (SELECT 0 as x union all

 SELECT 1 union all

 SELECT 2 union all

 SELECT 3 union all

 SELECT 4 union all

 SELECT 5 union all

 SELECT 6 union all

 SELECT 7 union all

 SELECT 8 union all

 SELECT 9 ) as a CROSS JOIN

 (SELECT 0 as y union all

 SELECT 1 union all

 SELECT 2 union all

 SELECT 3 union all

 SELECT 4 union all

 SELECT 5 union all

 SELECT 6 union all

 SELECT 7 union all

 SELECT 8 union all

 SELECT 9 ) as b

 ORDER BY 1

Rate

2.38 (13)

You rated this post out of 5. Change rating

Share

Share

Rate

2.38 (13)

You rated this post out of 5. Change rating